Had exact the same problem with my a40 last summer. There is a problem between the connection of your phone and battery, it has nothing to do with the percentage of your battery. You can try to let it fix, but I bought a new phone because the a40 is pretty cheap (not worth repairing) and it was a good moment for an upgrade.
Because you have water damage you connection between the screen and actual phone can be broken. Because an a40 is a pretty cheap phone it isn't worth to repair and you can better buy a new phone. You can try to connect your phone with your usb c cable and check on your computer to get any data but I'm not sure.