As an example, over here:
https://endless-sphere.com/forums/viewtopic.php?f=14&t=81108&hilit=luna#p1194271
I did some temperature testing of a pack under stress, and given that it rose in temperature from about 77F to about 101F, simply sitting in a plastic Samsonite case (with all of it's normal internal stuff removed, so it's just the plastics plus some styrofoam insulation top and bottom), I imagine completely encased in foam it'd've gotten hotter. And that was not a core measurement, just a barely-under-the-heatshrink one.
Since that starting temperature was when it was sitting in the breakroom at work for a shift, I imagine that when parked elsewhere, outside in summer heat, with time to soak up heat to reach the same as the 110F+ air temperatures (or much higher if in direct sunlight), that then the 24F+ rise in temperature would bring the pack to anything from 130-150F+ on the outer part of the outer cells, and the core temperature would be even higher.
I don't know what the self-ignition temperature of those particular cells is, but I can't imagine those high temperatures would be good for them even if they never reached dangerous levels.
Then as a second example, the EIG cells I use aren't put under much stress, and they also don't rise noticeably in temperature in use, from ambient (winter or summer). Encasing these on the trike are styrofoam sheets about an inch thick, mostly for the same purpose the OP wants the spray foam for--vibration damping / pack securing. They also provide some thermal insulation against the summer heat and the winter cold, but if the pack was under enough stress to self-heat greatly, I wouldn't use them, I'd find some other way to mount/secure them.
Regarding the wires, if I insulated the phase wires on the trike right now, they'd probably melt the insulation at least on the wires themselves, and perhaps whatever they were encased in--they get quite warm even out in the airflow under the trike even in cool weather.