Gnats can’t grow in dry soil, only wet soil with too much moisture. A moisture meter can help you avoid overwatering.
Whenever you bring a new plant into your home, add a sticky trap right away and separate it from other plants for 2 weeks.
If you suspect your plant has gnats, inspect the top layer of soil immediately after watering it. You’ll see the gnats squirming to the top and flying out of the soil.