Considerations for spray foam insulation with roof replacement possible in about 10 years
Spray foam is fine here. Hire it out, don't try yourself. You won't save much if any money and this stuff is better installed by pros. Make sure the roof decking is bone-dry on the day they install it. Determine what kind of R-value you want, too. The stuff is so expensive that installers will often try to convince you that 2 to 4 inches is sufficient for a variety of phony-baloney reasons; ignore that. If you want an R-50 roof (which is a good idea, and only slightly higher than code-minimum for your area in the latest version of the energy code), that'll require 7" of foam, which can very expensive. Typical price is $2+ per inch thick per square foot. for an 800 square foot attic, 7" of foam would cost more than $11,000!

Spray foam may be unnecessary. If you don't install the AC unit and its ductwork in the attic, then you can skip the spray foam and pile cellulose or fiberglass on the attic floor to get better performance for 1/3 to 1/10 the price. And it's easily DIY-able.