How much (legal) trouble can one employee get into with a smartphone and a social media account or two? Hint, hint: It’s more than most in-house counsel would want to admit. It’s enough to put a company in the HR hurt locker.

Let’s start at the beginning of an employee’s life cycle—vetting the candidate for an opening. Hiring managers love to peruse the candidate’s social media. For the manager, it feels like the only way he can get the real story on the candidate. Trouble is, the manager could learn something that kicks off a discrimination lawsuit. Maybe candidate Carl was once Carol. Or prospect Paula just found out she’s expecting and due in six months during the company’s busy season. Passing over either candidate could buy a trip to the Equal Employment Opportunity Commission.

But don’t abandon ship on social media checks. They can help an employer weed out employees with real judgment problems. There are options. For example, keep the social media checkout of the hiring manager’s hands and instead trust it to a trained HR professional who knows how to handle whatever turns up.

No-filter social media consumption can also stir up problems. Judging by many people’s activity on social media, HR would imagine they never got the motherly advice: “Keep your words soft and sweet because you never know when you may have to eat them.” It’s not hard to imagine in today’s politically-charged climate that someone could take offense. Add in the fact that co-workers are often connected. Any given company could be one “heck yeah” comment on the wrong build-the-wall post from a national origin discrimination lawsuit.

Cracking down on any employee post that’s less than genteel isn’t the answer. Employees have a right to gripe about the terms and conditions of their employment on social media together. Section 7 of the National Labor Relations Act says so, according to the National Labor Relations Board. Terms and conditions of employment can include touchy topics like the gender pay gap and supervisors. Even a profanity-laced post about the boss or the job won’t necessarily cross the line into fair game for discipline.

Social media can also spark a trade secret lawsuit. When the hot sales representative takes another job, management might not want to let his LinkedIn connections go with him. The connections, after all, do have some deep information on customers and targets. But the connections’ secrecy could be anemic. Depending on the sales representative’s account settings, one of his connections might be able to see all his other connections. Without clear expectations set when the LinkedIn profile is created, sorting it out can be a mess. A California court threw up its hands on summary judgment and tossed the issue to the jury. Check out Cellular Accessories for Less, Inc. v. Trinitas, LLC (C.D. Cal. 2014).

A strong social media policy is still an employer’s best bet. The policy should outline when access to social media is allowed at work and how it may be used for work. The policy should not be so broad that it chills all talk about work on social media but should prohibit any discriminatory or illegal conduct online. Although an employer should not outright ban online defamation, the policy should remind employees that they are individually responsible for what they post. Finally, the policy should prohibit disclosing the employer’s legitimate confidential information online.

Implementing a written social media policy—and training employees on it—will go a long way in protecting employers in this digital age. Employees are less likely to abuse social media when the company has made its expectations clear.