Fungus gnats in themselves will most likely not give you trouble, though they can be vectors for disease.

The problem is, if you have gnats, you also have created the conditions for mold to grow.

Somewhere in your grow you have a problem with either stagnant water (check drip trays) or too-wet soil that never dries out.

Fix this, gnats are gone.