You had the right idea. Open the
deck, remove the rotten balsa, dry out, then mix slow cure
epoxy with cotton fibre glue powder and butter the inside remaining glass layer. then bend your matched foam insert and
work it into the void on top of the glue driving out any air pockets, until the foam lies flat. Wobble it about to get it as level as possible. Use planks and pieces of foam across good
deck to hold it down until an initial set takes place. Then having ground back the edges of the cleared area, begin to replace the layers of deck fibreglass one layer at a time consolidating the glass and resin as one goes, finally using peel-ply to get a paintable finish.
I would NOT be using builders filler foam.
You CAN however make your OWN cellular epoxy putty which you can push into a tight space if it is clean and dry--it works well, gas to be done in stages because any exotherm has an effect, but that is another story. It works and works well--but for larger areas is not the best option.