I'm going to speak on this as a matter of social courtesy, not as TOS, because I don't like how these examples are grouped.
If you don't enjoy the dungeon, exiting as soon as you join I think is acceptable. I've accidentally queued for things I didn't mean to, and I think the sooner you leave the better off everyone is. Though maybe send a message to the party letting them know you didn't mean to queue for this.
If after 20 minutes things are not going well, it might be socially acceptable to quit. Although I think this is highly dependent on how much of an effort you made to teach and correct course. Sitting silent for 20 minutes and then rage quitting because you're not getting your clear is just kind of toxic. And honestly, no one should be pugging anything if they aren't willing to help the worst players, and are okay with maybe not clearing; to feel entitled to a competent random pug is I think somewhere on the axis of delusional.
Leaving after getting the item you need, that's just a dick move. The only conceivable situation I can think this is okay is if you tell your intentions to the group upfront at the start of the run. Though, in all honesty, if you were willing to run 1/4 or 1/3 of a dungeon/raid minimum, they aren't that long to begin with to just finish out the run for a little extra gold/loot. In fact, regardless of whether the party was informed of the situation, just seems common courtesy to help them finish their run.
The last example was really what triggered my justice muscle and made me want to post here. It amazes me how online culture skews people's sense of social responsibility and normalizes people getting away with all kinds of toxic behavior.
