Fungus gnats thrive in damp, exposed soil, and it's not the gnats themselves that pose any threat to your flora, but rather their larvae, which gnaw at any and all soft, young growth. They'll damage roots, hollow out slow-germinating seeds and devour delicate seedlings entirely. And once a breeding population is established around your plants, your horticultural ambitions are in big trouble.
If you have an infestation, check all your plants: any with larval infestations in their roots will need to be taken outside and re-potted in sterilised compost (to do this, spread compost on a plate and microwave it for at least 10 minutes, or oven cook it for an hour). Immerse the plant for several hours in a bucket of clean rainwater to drown/wash off any grubs, check and double check the roots, then re-pot in the sterile compost. Do this far away from your existing plant area where the gnats are inhabiting, and keep the re-potted plants quarantined away from the infested ones until you've worked your way through your whole collection.
Once re-potted, keep the sterile soil covered with a layer of sand or diatomaceous earth. It's best to water from below from now on to preserve this dry top layer, or if you have to water from above, poke a temporary crater and pour slowly. If the gnats are particularly aggressive they can even burrow up through the drainage holes in the bottom of pots to lay their eggs; prevent this with micropore tape over the holes. If you want to introduce predatory nematodes, now is the time to do it.
Once you've eliminated the larvae population, and all available breeding environments, the swarm will begin to diminish. Fly paper and soap & vinegar traps will deal with bulk of them. Carnivorous plants are also handy allies, but require fairly humid conditions to survive (letting them dry out and go crispy will only attract worse pests than the gnats you're trying to kill).
FYI To re-establish a healthy microbiome in your sterilised pots, brew up and apply a 12-24hr compost tea.
Sometimes I believe that this less material life is our truer life, and that our vain presence on the terraqueous globe is itself the secondary or merely virtual phenomenon.