Let the team decide who they want to work with instead of somebody else deciding for them
Why Corporate Culture Is Toxic For Software Development
Fagner Brack

There is of course a difference between not wanting to work together for justified reasons of deadline, resources, timing, planning, etc. and not wanting to work together because of personal opinion.

Ideally we all would love to work with people or groups doing things we are also interested in. To work with people we like. But that’s not always the case and yes, being forced to work in certain cross-group projects can suck.

Many of these advice are not binary choices, there is a spectrum to each of them. Finding the right balance is really important. But in general I do think it stands true that the participants of the team should be given an ability to have a say in the group process as a whole. None of use want to feel like robots churning results.