It really depends on the type of gnat/fly. Fungus gnats are relatively harmless and usually don't mess with eggs. I see a few fungus gnats here and there in moist substrate. I don't even worry about it at all. Now, phorid flies are an entirely different story. Phorid or humpback flies look similar to fruit flies, but they don't have red eyes and tend to "run" around before taking flight. Most gnats and flies immediately fly away when disturbed. Phorid flies are attracted to rotting organic matter (dead crickets, feces, etc.), and they reproduce like CRAZY! They WILL go after bad or infertile eggs that are allowed to rot and decay. If you have these flies in your collection, find the nesting site(s). Keep your cricket bins super clean, and make sure that you remove poop and any decaying matter as soon as you discover it. Phorid flies can easily spread diseases since they like to frolic in poop.
Nathan