I tried the spray foam before cutting a 2" piece of pink styrofoam. The spray foam was a mess, probably overfilled it and didn't dry properly with air voids. My testing with hot water in the cooler showed it made no difference.
The insulation lid (wrapped in a food grade bag - my mash tun is round and the lid fits in a turkey bag) made a huge difference with holding the temperature of hot water for testing. An actual mash can easily be held to a degree with a little mixing at 5-10 minutes into the mash to even out thermal gradients.
Wrapping it well in aluminum foil or wide plastic wrap sounds like a great idea.
Wrapping the mash tun in a blanket also is a good idea because it's so easy.