Have you checked the data sheet for your particular ESP32 module? I could not identify which particular version you have. The data sheet should give you all the information you require to use the module correctly.
I would expect the two GND connections are separate, and when used correctly that will prevent exactly the sort of problem you had. What does the data sheet say about which GND to use for which purpose, and how you should connect those and the associated power pins in particular?
With complicated devices that operate at VHF & UHF frequencies, it is essential to do exactly as the data sheet recommends.