Do it before acquiring any more fish. This is tricky though, as the current death-causing whatever is unknown, and changing the substrate will be highly stressful, and stress on top of already-stressed fish is anything but advisable. But, assuming the issue gets resolved, the plan should be:
Set up a temporary tank, have some substrate on the bottom, Use water siphoned from the existing tank, siphon it from the surface before you start any of this so it is clean and well oxygenated. Move over the decor and plants. Move the filter over without any cleaning, and the heater. Cover the surface with floating plants, I usually lay the taller plants on the surface rather than planting them. Net the fish over. Make sure the temp tank has a cover, fish will jump. And the whole idea with this temp tank is you can leave the fish overnight or a day or two if needed. You do not want to be rushed. Start early in the morning, about an hour after the tank light comes on to avoid more stress.
Remove the substrate from the existing tank. Rinse the sand and dump it in. When you have enough, arrange the hardscape. Add some water, maybe half, and plant the substrate-rooted plants. This will make quite a mess, so drain all water out and refill using a bowl to avoid stirring up the sand. Make sure it is the correct temperature as you fill it, don't expect any heater to heat cold water at this amount. Use the dechlorinator at this fill. If all is good, move over the filter, again without cleaning it. Net the fish over.