While it’s illegal to embezzle money from your employers, it’s apparently OK to deduct the legal fees from your taxes once you get caught, according to a 2009 court decision.

The case, Gordon v. United States, was highlighted recently by tax expert Robert Willens on CFO.com. The case involves a former Merrill Lynch energy trader, Daniel L. Gordon, who was accused of diverting about $33 million to accounts he controlled in 2000 and falsifying books and records. He pleaded guilty in 2003 to charges of wire fraud, money laundering, and conspiracy to falsify books and records. For his defense, he paid $319,754 in legal fees, and he wanted to deduct the money from his taxes.

Oddly enough, the court agreed that he could deduct the fees, relying on a Supreme Court decision in the case of Tellier v. Commissioner. The court found the legal fees to be ordinary and necessary business expenses because Gordon’s falsification of the books and records actually helped Merrill sell Gordon’s energy-trading division for a higher price to Allegheny Energy Supply.

He may have been ripping off the company, but he ultimately helped Merrill inflate the value of its Global Energy Markets division. It wouldn’t be surprising if Enron’s former executives and their attorneys are paying close attention to this decision.