if you are talking about fungus gnats (little black tiny flies) they are mostly harmless. since aloe vera plants can likely handle a more mineral soil perhaps you should change the soil to a mineral based cactus mix and see how that goes? and perhaps step back on the watering. those are my thoughts.
i've had some bad infestations of fungus gnats that i took the houseplants outside and put them under a tree for the rest of the summer. had to remember to water them but otherwise they did ok. came back in in the fall. once the plants died back for their normal winter dormancy i repotted them all in fresh potting soil and haven't had a repeat incident yet.
i keep worm buckets and sometimes the fungus gnats will try to get going in those too, but the past year or so i've been using little tiny spiders to capture them and it has almost been working (except in one case where there were just too many fungus gnats for the tiny spiders to keep up with). that bucket went entirely out into the gardens this past May planting time so that took care of that problem. i also transplanted some of the spiders into a few gardens to encourage them to capture some of the bugs out there. i'm always trying to add diversity to my gardens any way i can. all of the worm buckets i have wood lice, springtails and other soil community creatures that will keep busy breaking everything down for me while i'm getting ready for the next year. since i just restarted all the buckets i won't know how they're really doing for a few months and then i will start making sure they all have some of each kind of soil creature i can detect in them. it keeps me amused in the winter and gets my hands dirty a little bit...
um, ok, i do wander around in my ramblings too here on TEG... haha...