I've tested this out on many S series devices with this bug and it's actually pretty simple to make it go away if the inside of the port is clearly dry. Plug your USB cord into the phone, when the alert starts going off do a hard power off(hold your power button and the volume down button on the sides of your phone), the phone will turn off, let it stay off for 2 or 3 seconds(do not remove the usb cord!) and turn it back on. Now it will work fine. The only reason this would not work is if your port legitimately has moisture in it, in which case, clear the port of debris and let any moisture trapped in it escape and follow these steps again if it's still doing it a few hours later.
This didn't work for me on my s10. I'm still getting the moisture detected in usb charging port and it won't go away. Can't even connect to my Windows PC with out it happening. I've tried drying and blowing out the USB port, different cables and charger and everything else including factory reset and nothing has worked. Hopefully Samsung support can fix it.