Moonbeam won't remove the benefits of invisibility
Moonbeam does not say the flames render invisible creatures visible or remove the benefits of their invisibility. Compare this for example with Faerie Fire, which outlines the creature in colored light, and explicitly says:
the affected creature or object can't benefit from being invisible.
Moonbeam does not say that. If it was automatic, faerie fire would not need to say it either. This is in line with the principle that spells do only what they say they do.
You can imagine this as the flames not giving off real light, for example (they are ghostly, after all), or maybe as the flames also being made invisible, if you like.
One benefit of invisibility is that you can hide in plain sight. The image of invisible creatures being outlined by ghostly flames, and thereby not hidden any more even though they themselves remain invisible is pretty cool and also seems logical, so ask your DM how they handle it. They might rule otherwise.