it might possibly be expanding foam rather than fungus (light yellow, rigid, and needs a serrated knife to cut it. Sometimes people use it to block draughts, but it can hold damp). If it is weak and gives way to a pencil (possibly issuing a fine dust of spores) you have a much more serious problem.
the floor is badly damaged and needs to be replaced. perhaps woodlice have eaten it away, or woodworm.
I'd suggest a carpenter to take up and replace the floor and examine the joists. S/he might know a local plumber who can remove the bath. Most of the work will be in smashing carefully removing tiles round the rim, so plan to renew at least the bottom row.
Dealing with the floor, the carpenter should be able to identify and cut out/sister damaged joists. If it was me I would always treat joists and wallplates in a bathroom with a wood preserver that kills rots and insects. 5 litres will be plenty and might cost about £30. The modern water-based ones don't smell as bad as the older spirit based ones. If you have a choice of colours, get a green one. Cuprinol is the market lerader and makes "5-star" Screwfix sell an import which is probably similar. Sweep and hoover up all dust before applying it, or you will waste it treating the dust and dirt.
A suitable material for a bathroom floor is 18mm WBP (now called category 4) Ply. Or 25mm if you want to tile it or match the floor height in an adjacent room. 25mm is much more expensive. Some people will tell you it's marine ply, but it isn't really.
suitable
some Homebase offer a cutting service
B&Q ply was I found poor quality.
the full-size sheets are best value but very heavy.
very good
another brand
cheap one
you need plastic gloves, eye protection, overalls. They are intentionally poisonous.
If your carpenter will allow you the time, it is best to treat all edges of the ply with a few coats of varnish or paint to prevent damp getting in. I use a water based diamond floor varnish which is fast drying.
Without wishing to be impertinent, if you can afford it, this is a good time to treat and renew the whole bathroom floor, and put in a new bath, taps and waste. You'll need a plumber anyway to take out/put back the old bath.
Here's one I did this month. You may find it hard to believe it is made of 18mm WBP hardwood faced ply, and I have done the plank effect with wood dyes. Satin varnish. If you get a professional in they will not want you getting in their way so you would have to do it after they'd finished (or perhaps overnight)