It depends on the foam.
Some foam is only for insulating around windows. It's fluffy and breaks down.
Some foam is expanding, which on some tubs can push up the bottom.
If the tub has a plywood reinforced bottom, then you can use that type, but make sure the tub is filled with water first to keep the expanding foam from floating the tub.
The mortar mix, a few piles that can squish out is the safest method that I've found.
Not the only method, but a safe method.