Spray foam sounds good at first but it's almost always complete trash. Nasty chemicals, 0 ventilation, poor humidity management, pain in the ass to remove. It's one of these things poor people get because it's cheap upfront but in the end it'll cost you twice as much as a proper insulation system It's easy to apply and looks cool so that's good for instagram builders/remodelers, plus they'll probably be out of busine…
There's a whole class of corrosion in metal structures called Corrosion Under Insulation or CUI. This is a problem for any insulated metal structure, but it is way worse with spray foam because the foam traps moisture very effectively, when it breaks down it becomes acidic, it is difficult to remove for inspection or repair, and it makes hotwork dangerous because it is flammable.
When I started seeing wooden houses and roof decks get spray foamed, I could only think that these structures will likely be rotten and useless in 20-30 years. I would only sprayfoam something if the substrate is completely impervious to moisture, like if it was fiberglass or something. Even then you're likely looking forward to a pretty evil concoction under that insulation in a decade or so.