Unfortunately, there's no easy answer to this question, and a mistake can land you in jail. Illegal tape recording can have both criminal and civil penalties. My advice is almost always: When in doubt, don't.
Still, many employees want to record a boss or HR at work, and there are good reasons to do so. If you have a sexual harasser, it's handy to catch them red-handed. It's hard to deny something a judge or jury can hear in the harasser's own voice. Some employees want to record meetings with HR to make sure they get all the important information or to have evidence of the reason given for termination or discipline. Other employees want to get evidence of discrimination or other illegal practices of the employer.
Here's what you need to know about recording conversations at work:
One-party consent: In most states, as long as you're a participant in the conversation, you can record at will. South Carolina is one of these states, but the employee who was arrested taped a conversation between other employees, not herself. That's not allowed, even in one-party consent states
All-party consent: Thirteen states, California, Connecticut, Florida, Illinois, Maryland, Massachusetts, Michigan, Montana, Nevada, New Hampshire, Oregon, Pennsylvania, and Washington, require all parties to the conversation to consent to being taped. Hawaii, a one-party consent state, requires all-party consent if the device is installed in a private place. A Florida government employee was arrested a few years ago for giving a reporter a tape recording of a conversation she had with a supervisor. She cut a deal for community service, so we don't know how her trial would have turned out. These laws are sometimes referred to as "two-party consent" laws, but if there are three people in the conversation, all three must consent. For a detailed state-by-state survey of workplace surveillance laws, Justia has a summary of laws by state that can give you more details on your state law. The Digital Media Law Project has another handy state-by-state resource here but it is out of date.
Expectation of privacy: You can almost always record conversations in public areas, because the courts say there's no "expectation of privacy" in those places. Whether or not you are a party to the conversation, if it's out there in public, you may be allowed to tape it. Here's where it gets tricky. Many courts have held that there's little or no expectation of privacy in the workplace. There are cases saying, for instance, that a party to a conference call has no expectation of privacy.
As an example, cases in my home state of Florida on the expectation of privacy at work say things like: "Society does not recognize an absolute right of privacy in a party's office or place of business." "[A]lthough defendant may have had reasonable expectation of privacy in his private office, that expectation was not one which society was willing to accept as reasonable or willing to protect." "Society is willing to recognize a reasonable expectation of privacy in conversations conducted in a private home. However, this recognition does not necessarily extend to conversations conducted in a business office."
The problem I have with relying on cases like these to tape at work is the use of weasel-words like "necessarily" and "absolute" and "reasonable." These cases are very fact-specific and that means a court could still find that your boss or coworker had an expectation of privacy. If you get it wrong, you can end up in jail. That Florida employee who was arrested for taping in a public building should give you pause about relying on these "no expectation of privacy" cases too heavily.
Retaliation: If you record a conversation to document illegal discrimination or illegal harassment (we're talking harassment or discrimination based on race, age, sex, religion, national origin, disability, pregnancy, or other protected category, not bullying), then you may or may not be protected against retaliation by your employer. The courts have split on this issue. Depending on your state, your employer may be allowed to fire you for recording a conversation at work (even though they can't fire you for reporting discriminaiton).
Getting permission: One way to get around problems in all-party consent states is, when in doubt, pull out your recorder and turn it on. Say, on the recording, "You don't mind if I tape this do you?" If the other person or people say they don't mind, keep recording. If anyone objects, turn it off. Pull out a pad of paper and a pen and take good notes instead.
Creative ways around: I had a case where one creative employee knew the harasser was approaching her office so she called a friend and put her on speaker to listen. That way she had a witness. Even taking notes helps bolster a case. Your notes can be evidence.
Other evidence: Don't forget to save things like text messages (take screen shots and print), emails, Snapchat and other social media. Don't let that stuff be auto-deleted or lose it when you drop your phone in a toilet. It's your burden to prove your case, and losing evidence can be held against you. Have nothing in writing and no witnesses? Your own testimony is evidence. If you come across as credible, that could be enough.
To summarize, you can probably tape a conversation at work that you're part of as long as you live in one of the 37 one-party consent states. You can also possibly tape a conversation that's in a public area (lobby, office or conference room with doors open, stairwell). You can maybe tape a conversation in the office behind closed doors. If you get it wrong, you're in possible criminal trouble, so be careful. Even if you get it right, you can probably be fired for the recording.