Syg those flatworms are something all of us have to deal with. They hitch a ride in on frags and live rocks we buy from fish stores or other tanks. They make medications to add to them but I recommend we wait, if it was my tank Id clean the algae first and then handle those flat worms, no reason to run concurrent meds.
In my vase when I used to get those I never added meds for them. they would congregate on the glass sides eventually and during a water change I would take a paper towel and wipe up and out when the tank was drained (you can do a lot of work on a tank when its drained)
by removing the mass as best I could they just died out and didn't come back because I started dipping new frag bases in peroxide to kill all hitchhikers. It also helped that my tank was full of corals and had no more room for additions, this cut down on my list of invaders significantly. I would siphon those out off the sandbed, and replace a handfull of new sand wherever needed. that will keep them controlled until you are ready to start stronger target meds like flatworm exit etc, and, they may die off anyway without cause like they did in my tanks. no hurry on those guys, the algae is more of a risk to your tank