The Internal Revenue Service has long taken, for obvious reasons, a dim view of classifications of revenue that diminish tax liability. One of the prime means of doing so is where a closely-held corporation (especially an S-corporation) classified payments to its shareholders, who work for the company and provide it regular services, as dividends rather than as salary.
The IRS's rather oblique guidance on the subject reads:
S corporations must pay reasonable compensation to a shareholder-employee in return for services that the employee provides to the corporation before non-wage distributions may be made to the shareholder-employee. The amount of reasonable compensation will never exceed the amount received by the shareholder either directly or indirectly.
What the IRS will consider reasonable will likely vary widely from one company to another. For a recent decision on the topic, involving the opposite situation (a corporation misclassifying dividends as compensation to take deductions deemed improper by the IRS), see T.C. Memo 2016-20.