CHICAGO – If you're the kind of incurably cheerful employee who whistles while she works, feel free to tootle out another happy tune.

That's the verdict — more or less — of the 7th U.S. Circuit Court of Appeals, which has ruled that being miserable at work isn't a strict legal requirement.

Workers can thank — or if they see fit, blame — a septuagenarian racehorse trainer for forcing the issue in a fight with the taxman.

Merrill C. Roberts, who loves his job so much he's still working at 74, fought back against the Internal Revenue Service after it ruled that his Indiana horse training ranch was a "hobby" and not a business that qualified for tax breaks.

But after a U.S. Tax Court judge agreed with the IRS and slapped Roberts with $225,000 in back taxes for 2005 and 2006, Roberts appealed.

And recently, as work-loathers across the nation celebrated the start of the weekend, the Chicago-based appellate court backed him in his right to enjoy both his work and a full set of business tax deductions.

Judge Richard Posner, writing the ruling for the three-judge panel's unanimous decision, said Roberts' stables "may have been a fun business, but fun doesn't convert a business to a hobby. If it did, Facebook would be a hobby, Microsoft and Apple would be hobbies, Amazon would be a hobby."

While the IRS and a Tax Court judge had held that Roberts' enjoyment of the recreational and social aspects of horse racing suggested he was not motivated by profits, Posner disagreed, finding that although Roberts had made his fortune in the restaurant industry earlier in life, "it's not as if he were a billionaire indifferent to the modest profit that probably was all he could expect from horse racing."

Posner approvingly quoted a ruling from a prior case that "a business will not be turned into a hobby merely because the owner finds it pleasurable; suffering has never been made a prerequisite to deductibility."

Speaking Monday, Roberts said he'd spent $400,000 fighting the case after a young IRS agent "who couldn't tell a horse from a pig" audited him eight years ago.

"I don't know why anyone would do a job for 15 years if they didn't like it," he added. "I enjoy it, but it's hard work — I get up at 5 a.m., some mornings 4 a.m."

He declared his victory "a win for all horsemen" and said he hopes his luck carries over to this weekend, when his horses race for the first time this year.