And here’s me about two hours away from my copy of the Star Trek: The Next Generation Technical Manual to debunk this obvious joke with a picture of all the architectural diagrams where it calls out places where one might find a head, including, IIRC, the Ready Room, of which I imagine Riker probably avails himself on the regular.
I mean, they have a transporter right? Couldn't they just beam waste into a holding container or out into space? In discovery they say they recycle everything so maybe it just gets beamed to Kieko's Arboretum lol.
The whole idea of Replicators and Transporters is that they have some technology which can efficiently convert matter and energy, so it's possible that they use some sort of reverse-replicator to process waste.
You also never see what they do with the glass cups the replicators create when someone asks for a drink...
By the 32nd Century, it is confirmed canon that human waste is directly reused for food replicators. "It's pretty good for shit." - Admiral Vance
It's less clear whether that's true for earlier eras or not, but the existence of "matter recyclers" sure implies it.
But all this still doesn't address the matter of where people poop on a starship.
Surely the bridge crew all have their own freshers, but what about the lower decks? Do they have communal restrooms? What about accomodations for different species needs? Is there a diplomatic lounge with a wide variety of bathrooms available? When they have guests from a different species they're not familiar with, is there an ensign whose job it is to research that culture's bathroom customs and ensure they have the appropriate facilities replicated and constructed? Is there maybe a small holodeck reserved for this purpose? These questions need answers.
My headcanon is that in public / guest quarters the toilet stalls contain miniature holodeck emitters so that they can instantly change to accommodate the customs / biology of any species. Even assuming that, say, Klingons excrete waste from the same places that humans do, they might prefer to do so while dangling from a bar in the ceiling or something else torturous like that, and find the use of a regular sitting toilet unclean or dishonorable.
new headcanon: klingons actually have extremely prim and proper toilet habits, to pee standing or leave without washing your hands is immediately punishable by dishonorable death. They WILL NOT do number 2 without confirmed access to a bidet.