A few years ago I had an infested pothos. I read up on fungus gnats online (there’s plenty of information to be found) and tried several recommended remedies: letting plants dry out well between waterings; putting a potato slice in there for larvae to grow on and then discarding it, several times in series; putting the plant outside on the porch on cold nights; etc. I didn’t notice that any procedure had an effect. The gnats would seem to disappear for a few days and then be back in full force.
As I often do with seemingly intractable problems, I got tired of trying before the problem was solved and just gave up for a while, figuring I’d come back to it later. I think the gnats got bored with the game once I was no longer playing, and they just left.