^ Hope you see this before its too late. ^

Spray foam is extremely flammable. A fault in your panel would cause big fire concerns. The best thing to put in direct contact with a panel is nothing at all. Failing that I would do roxul. It wont burn under a direct flame and can be removed if necessary.

Spray foam also makes maintenence or future wiring impossible.