The adults lay eggs on the soil surface, so the related method I heard of was to stretch the panty hose over the top of the pot with a small hole for the plant to poke through, keeping the flies from getting to the surface. I wouldn't have been thought they'd be able to get at the medium at the bottom unless maybe the drainage holes are on the sides. The larvae can be at the base inside the pot though, so mesh there might stop the adults they turn into from getting out, unless maybe they are able to make their way to the top and get out there.