Gustav Le Bon's book "The Crowd" explains group behaviors (and misbehaviors). The context may be, say, the French Revolution, but the behaviors are the same as exist in social media today.
The Crowd: A Study of the Popular Mind : Gustave Le Bon https://archive.org/details/crowdastudypopu00bongoog