Jay Van Bavel and Dominic Packer are social psychologists whose recent book, The Power of Us, is a nice review of basic social psychology with a unique emphasis on the impact of identity and group affiliation on human behaviour and cognitive biases.
This book would be an excellent accompaniment to The Righteous Mind, by Jonathan Haidt, and Blueprint, by Nicholas Christakis. Haidt looks at individual differences in values as a factor affecting group behaviour. For example, people who value loyalty and "purity" (as opposed to "compassion" or "fairness") as cardinal values may be more likely to have strong group adherence, and may be more accepting of hierarchical or paternalistic systems; such traits could lead in particular to involvement with conservative groups. Haidt argues (and I strongly agree) that such values and traits have a strong hereditary basis (though are also partly influenced by environment & cultural milieu) and have evolved in humans due to selective advantages for those who have a strong inclination towards group affiliation. But of course, too much loyalty can be a bad thing, if it causes people to adhere loyally to groups which are engaging in harmful behaviour--we see this problem in the news every day. Christakis looks at group dynamics in an interesting mathematical way, with successful or unsuccessful group behaviour influenced by the structure of connectedness, which in turn is influenced by leadership styles, external factors, and individual personality traits.
The subject of group affiliation, identity, with associated biases, polarization, and conflict, is an incredibly important subject in the world today. Group-based divisions arguably are a primary cause of political problems and war across the world, and lead to delays and inefficiencies in solving world problems such as poverty, environmental degradation, and war. On the positive side, strong group allegiance has led to most of humanity's great achievements through history. Most great accomplishments in the sciences, the arts, in politics, and in the law, involve large-scale collaboration.
Group affiliation is a powerful source of identity for all of us. If we have a strong attachment to a group, we are likely to favour ingroup members. This is normal and ubiquitous, but it can lead in an extreme case to hating or persecuting outgroup members. To prevent this, it can be helpful to have a culture of interacting respectfully or collaboratively, or recreationally, with outgroup members (Jonathan Haidt made this point years ago, in The Righteous Mind). It could be especially effective if any such recreational activity could blend members from different groups. The authors cite some very successful examples of these ideas, such as having a soccer league in Iraq where each team was required to have players assigned equally from different conflicted religious groups. The resulting games allowed each player, and each team, to like, respect, and enjoy outgroup members, since they became teammates, leading to reduced conflict in their communities afterwards. A famous example from classic social psychology research is the "Robbers Cave" experiment from the 1950s, in which antagonistic groups of teenage boys later worked together in friendship and harmony if they had to collaborate together to solve a problem external to them both.
The chapter on "fostering dissent" is especially insightful. The authors make the point that voicing a dissenting opinion within a group is socially costly. Even if the dissent is about an important logical or moral issue, the risk of dissenting can be to make other group members angry, and therefore threaten one's position as a group member. You risk being seen as disloyal or disrespectful. They argue that you have to really care about your group to be willing to voice dissent. I see this could often be true, but sometimes particular individuals are more oppositional or defiant, due to character traits, leading to frequent dissent even if they don't particularly care about their group status. Another problem with dissent is that other group members may have quietly agreed with the dissenter's position, but it could be costly for them to endorse the dissent, since it could make them look bad or immoral for not having brought it up first. So a default position in groups would be to maintain the status quo, and for dissent to be risky, even if the group is engaging in harmful behaviours or beliefs. Unfortunately, this can cause harmful behaviour to be perpetuated in some groups, and for dissenters to be punished or ostracized. Recent examples of this include U.S. politician Liz Cheney, who has spoken out against the deeply immoral behaviour in the leadership of her political party. Unfortunately, she was defeated in the subsequent election. While she should be seen as someone defending the honour, integrity, and values of her group, therefore protecting the group's long-term interests, she instead has been seen by her own ingroup members as disloyal, and punished for it. I hope her own story is not over, and that her principled behaviour may prevail in the end.
An approach to solving the dissent problem is to have a leadership structure or ethos in groups which encourages respectful disagreement, without fear of punishment or other consequences. Also it is vitally important, as a persuasive factor, to frame dissent or challenge with the group's long-term well-being in mind--to remind others of the group's core values, of the group's long-term interests, with a dissenting view intended to be a service to the group rather than merely a criticism.
On a larger scale, I think it is always helpful to expand the circle of our groups. Instead of focusing on local or national or religious or political allegiances, why not focus on a shared humanity. Some of the guiding insights of many of the world's religions, such as Christianity, were to expand a circle of love, respect, and inclusion to outgroup members, and not to shrink into insular, bitter enclaves judgmental of others outside of their own ranks.
Psychiatric issues always exist in a social context. Patients will always have group allegiances or identities. These could involve religion, politics, gender, race, family, occupation, etc. It is important to understand these group allegiances, empathize with them, and communicate therapeutic ideas with the group allegiances in mind. Encouragement or advice for change carries a high risk of failing if it is expressed in such a way as to challenge a person's individual or group-based values. A survey of group affiliation and identity factors should be an essential part of a psychiatric history, and an ongoing theme in a therapeutic dialogue.