This is supposedly also a trick for maintaining hydration while drinking diuretic beverages. (So I’ve heard about certain Belgian monks during Lent, but it’s dangerous for hopefully obvious reasons. Please do not do this!)
From what I’ve read, drinking caffeinated beverages still will give you a net positive hydration, there is some diuretic effect but it is not strong enough to offset the water in the drink.
Sometimes there really is no coffee to find, though.