In the US: When you have legal counsel powerful enough to expose it as so (while simultaneously capable of protecting your constitutional rights and livelihood.)
At my work my bosses were sued for age discrimination, violations of the Americans With Disabilities Act, and gender discrimination, to name a few.
Sometimes the suits had merit, but most of the time it was because someone didn’t get their way.