There are not many things more satisfying than filing your tax return and finding out you are getting a refund. Everyone is thrilled when they learn the IRS owes them money. But just because the federal government owes you money, will you actually receive it? Many people ask if the IRS can keep their refund. As with many questions about the IRS and taxes, the answer is complicated.

Generally, if you do not owe any back taxes or money, then no, the IRS cannot keep your refund. However, there are instances when the agency will keep the money owed to you. Here’s a look at those situations.

You are making payments for another federal tax period. If you are currently paying money under an installment agreement or payment plan, the IRS will automatically apply any refund due to you against taxes you owe. This means that if you owe $1,000 for a previous tax year, but you’re owed a refund of $500 for tax year 2018, the IRS will apply that $500 to what you already owe. If your refund exceeds what you owe, you will receive a refund for the amount over what you owe.

You owe child support or spousal support. If parents have not paid court-ordered child support, the state’s child support enforcement agency may ask the Treasury Department to withhold any tax refund owed to cover the delinquent child support payments. This same situation can be applied if you owe court-ordered spousal support as well. Your refund could be held or used to offset overdue payments.

You owe unpaid student loan debt. If you are delinquent on federally insured student loans, the IRS can keep your tax refund and apply it toward the debt you owe to the U.S. Department of Education. Additionally, your state could also withhold money from your state tax refund.

You owe state income tax. This is another situation in which the Treasury Department can withhold your tax refund and apply it toward any outstanding state income tax that you owe. Additionally, if you were in a situation where you collected more state unemployment compensation than you were entitled to, then your federal tax refund can be used to offset that amount.

You’ve filed for bankruptcy. Being in bankruptcy is not an automatic way for the IRS to keep your refund. However, your bankruptcy trustee can ask the court to take your tax refund and apply it toward your debts.

Like most issues, you don’t want to navigate the IRS and taxes on your own. Consult with a tax professional or experienced tax attorney when it comes to all matters of tax refunds and the IRS.

Allison Soares is a partner and tax attorney at Vanst Law. It doesn’t matter the issue: audits, collections, appeals, international disclosures, grumpy people— Allison enjoys fixing problems. In addition to her legal work, she has worked in accounting and utilizes that knowledge to her advantage while handling cases involving EDD audits.