Moisture will build up wherever there is a cold surface next to warm humid air.
(think of a cold pop can outside...oh sorry..soda or coke for yuh sutherners..

)
Closed cell spray foam will provide a vapor barrier to the outside as long as it wraps around the surface continuously.
Even an inch is better than gaps.
That slanted walkway with the water heater is now considered "outside" air.
It wants to transfer and steal heat to both the side wall and the floor underneath.
I would spray the underside of the roof and rafters and outer wall to include that space inside the "heat envelope" or "conditioned space".
The one drawback might be that there is probably no active air flowing through it.
A few vents at top and bottom would allow some natural passive circulation through it and help prevent moisture buildup.
Some air movement is needed everywhere but in the right direction.
In the meantime, spray down everything with a 10% solution of bleach in a spray bottle.
Be warned that closed-cell foam has isocyanides and will make you seriously ill for the first couple days to a week while it is off-gassing.
Do not mess around with that stuff.
I got sick when my home was done, and also later when spraying it outside with a 2-part tank kit from HD.
Even the 3M chemical masks are not enough..
Rent a fresh-air suit kit with hoses and everything if you DIY. Seriously.