yeah, I'd love to see the pex-pix.
on the rot: painting and/or spray-foam doesn't cure rot.
and the plywood is an important structural element, especially back there. It needs to be cut out and replaced.
In this particular situation, its beyond rotted in a couple of spots; its "missing".
I did some temporary repairs to brace things up a while back, but it really should be properly fixed once and for all...which means, the bathroom has to come out...and also, the pipes that are in/around the area, which will be replaced w/ pex...and since it all has to come out, that would be a good time to paint the old abs plastic...etc, etc.