Hi....welcome to the Forum
Certainly sounds like water ingress in a body control unit.
Alternative thoughts are maybe it could be some wiring in the tailgate area so when the tailgate opens and closes it breaks the wiring in the loom which connects the two.
Can give loads of strange faults, easy to check and repair though
Let us know how you get on with it