Out in the cold or one of the gang: Initial contacts set the scene
https://www.sciencedaily.com/releases/2018/05/180529103614.htm
Positive experiences are repeated
By running a series of experiments, the researchers were able to confirm that social exclusion was not so much an instrument to discipline others, but rather an unintended side effect. This side effect arises when people choose to join up with individuals they have previously had good experiences with as a result of simple learning mechanisms. In other words, if the first random grouping in a social situation works out well, people have a tendency to repeat it. This means, however, that others are excluded from the interaction and thereby incidentally ostracized.