Ordinary taxpayers don’t always have to accept the IRS’s decisions about taxes or penalties—they can take the IRS to court.

Here are important lessons from two notable court disputes in which taxpayers prevailed and one dispute where a taxpayer’s mistake cost her some ­deductions…

You may be entitled to a tax deduction for education expenses while unemployed. Alex Kopaigora was a senior assistant controller for a hotel at the Los Angeles International Airport when he started an executive MBA program at Brigham Young University (BYU). Before he completed his degree, however, he lost his job. Nevertheless, he continued to pursue his studies at BYU while also looking for a new job in corporate finance. One month after graduating, he landed a position as vice president of finance at a small financing company. On his tax return, Kopaigora claimed an $18,879 deduction for his degree expenses ­including the cost of travel between California and Utah.

IRS Position: The agency disallowed his deductions, stating that education expenses may be deducted only to maintain or improve skills required in a current job or to maintain professional status. Since Kopaigora had been unemployed during the final months of his degree program, the IRS said that he did not qualify.

Tax Court Ruling: The court disagreed with the IRS, finding that ­Kopaigora was a well-established ­finance and accounting manager both before and after the degree program. The courses he took at BYU were within his field and served to improve his skills in that area. What’s more, while unemployed, he actively sought employment within the corporate finance and accounting field even during the remainder of his degree program at BYU.

Lesson: Even if you’re unemployed, you can deduct education expenses as long as your coursework maintains or improves your skills in your established field. However, if you are pursuing a degree to qualify for a new field or higher-level position, you can’t claim a tax deduction.

Kopaigora v. Commissioner, T.C. Summary 2016-35

To qualify for business-loss deductions, profit motive is more important than making a profit. Richard Main was a patent attorney who also ran a business that involved buying, restoring and selling 1955 and 1956 Plymouth automobiles, which he stored at his ranch in Livermore, California. Because replacement parts for Plymouths were hard to find, Main contracted with a jewelry maker and a rubber manufacturer to produce parts to use in his cars and to sell to other Plymouth restorers.

The car-restoration business struggled. The cost of producing parts exceeded sales revenue, and Main ended up terminating the contract with the producers. He also faced foreclosure on the ranch where he stored his vehicles and had to downsize his ­inventory and move several cars to a storage facility before spending $27,900 to build a garage at his new residence a few years later.

He eventually used several years of accumulated losses and other expenses as deductions related to his car-restoration activities to reduce one year’s taxable income to zero.

IRS Position: The IRS said that Main could not take deductions related to his automobile venture because it failed to pass the “hobby-loss rule,” which states that an activity is considered a business only when it generates profits in three of the last five tax years. Because Main’s car-restoration work didn’t do that, it was considered a hobby. As a result, the IRS assessed a deficiency in his taxes and a penalty.

Tax Court Ruling: The court found that the IRS was wrong in its interpretation of the hobby-loss rule because Main had established a profit motive for his automobile venture, and therefore he was entitled to deductions and expenses in amounts substantiated. The court cited his expertise relating to Plymouths…the effort he spent to advertise his cars online, in print and at live events…and his contracts with third-party suppliers.

The court also looked favorably on the steps he took to stabilize the business, such as ending the parts contract when it proved unprofitable and downsizing his inventory. Even though Main derived pleasure from restoring cars, the court said that it was clear he also intended the activity to be a business venture.

Lesson: There is leeway in the hobby-loss rule. The IRS’s requirement that a business make a profit in three of the last five years is not necessarily the final determination—because profit motive can trump actual profits. You can claim losses as long as you prove that you ran your business with the goal of profitability. Taking steps such as the ones that Main did to shore up his business is a good way to demonstrate that motive.

Main v. Commissioner, T.C. Memo 2016-127

Claiming a home-office deduction requires careful documentation. ­Diana Czekalski is a physical education teacher in Hayward, California, who traveled to several schools each day to work with special-needs students. Because the school district provided no office or storage space for Czekalski, she used half of her garage to store equipment that she used in her work with the children. She also had a home office where she prepared progress reports and time and attendance reports for the school district.

At the end of the year, she calculated that she used a total of 224 square feet of her 1,462-square-foot home for business purposes, and she claimed deductions for unreimbursed employee expenses related to her home office and daily use of her car. Czekalski also deducted the unreimbursed cost of a conference she attended in Long Beach, California, for educators working with students with disabilities.

IRS Position: The IRS rejected ­Czekalski’s entire home-office deduction and most of her unreimbursed travel and vehicle expenses, saying there was a lack of substantiation and assessed a tax deficiency of $7,147 on her income taxes and an accuracy-related penalty of $1,429.

Tax Court Ruling: The court handed Czekalski a partial victory when it determined that she met the requirements for deducting a home office—that is, she used her office (and half of her garage) regularly and exclusively for work, and her home office was her principal workplace or the place where she performed administrative and management tasks. In addition, she passed the extra test for employees with home offices—she used the office for the convenience of her employer, not just because she preferred working from home.

Czekalski had receipts showing that she paid approximately $5,200 in homeowner’s association dues, utilities and trash-collection fees, so the court held that she was entitled to a $778 ­deduction for the business use of her home (about 15% of her home expenses, equal to the 15% of her home used exclusively for business). However, the court did not allow other deductions, such as her vehicle expenses and conference travel expenses, because she failed to produce documentation for those costs.

Lesson: Some employees, such as sales representatives, have no dedicated, employer-provided space to perform administrative tasks. If you’re among them, you can deduct expenses related to business use of your home and other nonreimbursed business expenses…but you must keep detailed records and prove that you are maintaining a home office or traveling for the convenience of your employer. Czekalski was unable to claim much of her other unreimbursed expenses because of poor record keeping. If she had kept a log in her car that noted her mileage and had saved all receipts from her conference, she would have had all of her expenses allowed.

Czekalski v. Commissioner, T.C. Summary 2016-56