In my first year of law school, a classmate gave me some advice about choosing jobs: Pick the people you want to work with, he told me, not the position. How much you like your coworkers will determine 90% of your happiness at the office.

In the years since, I've come to realize more and more just how right my friend was. I've passed on assignments to avoid working with unpleasant editors, and will happily accept less than my quoted rate to keep working with good people. It turns out I'm not alone.

Far from it.

Numerous studies show that people decide to leave jobs overwhelmingly based on the people they work with, and especially their bosses. As one piece of research out of Accenture pointed out, of the four top reasons people gave for leaving a firm, all four had to do with management and personnel environment.

It's as close to a managerial truism as you can get that people don't quit their jobs, they quit their bosses.

But contrary to movies like Bad Bosses and 9 to 5, not to mention countless memes on social media, most bad bosses out there don't engage in outright villainy. They're not the Miranda Priestlies of the world, they're the Michael Scotts - petty jerks who just don't seem to get all the nasty little things they do every single day. They may even have good intentions. Usually, said James Manktelow, co-author of Mind Tools for Managers, they're simply poorly trained.

"It takes a lot of emotional intelligence to be a good boss," Manktelow said. "You need to be confident, authentic and positive. You need to be able to cope with pressure and stress without taking it out on members of your team. And you need to be able to inspire people, and deal gracefully with problems when they inevitably arise."

"It takes time, guidance and development to become this sort of person, and many bosses don't receive this."

The results?

"Poor judgment," he said, "bad temper, controlling behavior and an excessive focus on tasks at the expense of people. Over time, all of these are things that drive the best people - those who are highly skilled and self-motivated - away."

It's the last that may show up most pervasively in a workplace. Consider every job stacked with excessive forms, every rule designed to micromanage employee behavior. These are the managerial jobsworths. They create rigid task sheets and write evaluations based on how well someone ticks boxes rather than an individual's performance in the workplace.

These bosses focus on trivial tasks over personal initiative and obsess over dress codes instead of customer relationships. They are the TPS report obsessives, the time-keeping hawks and the ones who always keep score. They don't know how to evaluate people, so they evaluate action items and hope it comes out to the same thing.

Worse, this boss might be responding to directions from a corporate office. A human resources officer 500 miles away may have no idea that Janet plays golf with a big client, they just know that "Employee 2241" took five hours of unapproved absence last Thursday … and just like that, you have a workplace run for the paperwork, not for the people.

Meanwhile, the chances of Janet, someone with the talent and drive to get golf outings with big spenders, staying in that office in an increasingly tight job market? Slim to none.

This shows up most, Manktelow said, in industries with two key profiles. First, "Peter Principle" firms.

In these firms, employees get promoted based on job performance; for example, engineers who display strong technical competence or representatives with great sales records. This well-intentioned meritocracy meets well-intentioned policies of promotion from within, and the worker eventually reaches a position of management.

But because they reached a managerial role based on skills that had nothing to do with management, the employee is unprepared for their new job. They do it poorly, and so have gotten promoted to their level of incompetence, where (failing a true catastrophe) they remain. They have "petered out," per the term.

This used to be very common among computer firms. Programmers would rise through the ranks based on coding, not people skills, stocking the company with mid-level managers incapable team oversight.

The second most common profile for mediocre bosses is a high-turnover, low-skill environment. This may often be a retail or low-wage service industry position, one in which workers rarely stay very long so the corporation spends little on training or development. (Fast food alone has a turnover rate of 150% annually.) Due to high levels of customer interaction, these can be very stressful employee environments, but managers rarely receive the support or preparation they need to do the job well.

So what can you do about it, when stuck in an environment with a boss who is either a petty tyrant or simply clueless? Start with that most human talent of all: Empathy.

"The thing to do when you have a 'bad boss' is to try to understand him or her," Manketlow said, "and figure out what brings out the behaviors you don't want to see. What makes him angry or suspicious? What causes her to want to take control? And what pressure is he or she under from the person above?"

"Recognize that this person is just another human being trying to do a difficult job, and work out what you can do to make this job easier."

The last piece of advice here is key.

You may not like how your boss fails to understand you, but ask yourself, how hard do you work to understand them? They're not working to understand your workplace expectations and needs, but what have you done to understand theirs? Maybe they obsess over the dress code out of a misplaced need for control, but maybe they do so because they believe that customers subconsciously notice the smallest details of a business environment.

Remember that whether you like it or not, they are the boss. Work to help them feel like you're working to meet their expectations, and communicate that fact. If something goes wrong, explain it. Don't blow a deadline by 12 hours because it's no big deal, send an e-mail saying "sorry, here's why it's late."

It won't always succeed. Some bosses simply don't know how to manage a workplace, and then you may have to decide whether the job is worth the people.

It might make a bigger difference than you'd think.