I've had both: a bad colleague who went dancing while we were struggling at 23 PM in the data center for a government project, and a really shitty PM whose incompetence ruined a lot of people personally. Both can have adverse effects on people, although a bad boss in an otherwise sane environment would probably strengthen the group for being perceived as an external "enemy".
That has not been my experience with a bad boss. They do things like play favorites and create a culture where people are competing rather than cooperating. Even if they are just shitty to everyone equally I find it far easier to deal with a bad colleague than a bad boss.
> a bad colleague who went dancing while we were struggling at 23 PM in the data center
If that's your definition of a "bad colleague" I would be a little concerned. There are situations where it may be necessary to do that struggle, but in my experience there are far fewer than you think, and people often fall into a trap of competing to be the last one standing rather than actually doing good work. If you're struggling in a data center at 2300 you may well be doing more harm than good and going home to sleep (or dance, or whatever you need to refresh yourself and come back focused...) is often a better choice.
I always try to be pro-labor but i had such a situation in my own company. A person I tried to make work for months, the situation just got worse the OP describes (it wasn't performance issues but more attitude/social/soft-skills related). I hesitated before firing them, fearing effects on team morale. After firing them morale improved immensely.
The best thing you could have done is fire them 6 months ago. The second best is firing them today. Don't hesitate.
A decent percentage of the time the person 'management' sees as problematic is a problem because they are a threat to management not to the team.
If I had a nickle for every time management used the 'saving team morale' excuse to get rid of someone out of fear of them being promoted faster than thenselves ...