If you've worked for any length of time, you probably have had a “toxic” coworker — someone whose over-the-top demands, negative energy, and otherwise bad office behavior can drive the people around them crazy.

People with this type of personality can be effective in certain types of businesses, a new study finds, but when it comes down to it, these demanding prima donnas generally cost a company more money than they make for it.

In the short term, firing a toxic worker boosts the morale of the remaining workers and, in the long term, sets an example.

The Harvard Business School team looked at human resources data from 11 large companies, which included some 60,000 employees. They focused on employees whose behaviors ultimately caused them to be fired from the company.

Hiring a capable-but-toxic worker might boost a company’s savings by $5,300, through increased output; but the team calculated that not hiring one in the first place would save a company $12,500.

This is partly because when a toxic worker is in the office, other employees tend to leave the company sooner, which creates huge hiring and training costs. They also tend to sap the productivity of those around them.

“[It] turns out, we've all had personal experiences where we have a worker…[who], rather than really helping performance, actually hurt performance in one way or another,” study author Dylan Minor said in a statement.

There are other ways in which coworkers might cost the company money — like stealing property or committing fraud. But psychological attacks, such as through bullying or cyber-bullying, workplace violence, or sexual harassment, may ultimately be even more costly.

So how do companies weed out toxic applicants to begin with? There are some key indicators for predicting who might be a toxic personality once hired, the study found. Toxic workers tend to have high self-regard or selfishness. This makes sense, since it would make them less sympathetic toward their coworkers and less likely to treat them with respect.

The second indicator is over-confidence, which the authors say can lead to risk-taking and even illicit behaviors.

Finally, if a potential employee says he never breaks a rule, that’s probably not a good sign. “That is kind of counterintuitive,” Minor added. “…[T]hose that say 'Oh no, you should always follow the rules'… are much more likely to be terminated for breaking the rules.”

While it’s hard to fire a person who’s productive — or appears to be — as many toxic people may be, the costs of keeping him or her on board far outweigh the benefits. In the short term, firing a toxic worker boosts the morale of the remaining workers and, in the long term, sets an example. “Literally, the worst thing to do is to not do anything, which happens a lot, unfortunately,” Minor said.

If you work in the presence of a toxic person, it might be worth talking discretely with your human resources department or a trusted colleague. Your boss might not even be aware enough of the situation to do something about it. And as earlier research shows, being surrounded by positive rather than negative interactions at work is not only linked to happiness, but it’s also linked to better health.

The study has not yet been published in a peer-review journal, so its findings should be considered preliminary.