HSA Tax Strategy: IRS-Compliant Receipt Tracking with Beancount

As a tax preparation specialist and former IRS auditor, I’m seeing more clients ask about HSA strategies this year. The triple tax advantage is real, but there are critical compliance issues that plain text accounting can help solve.

Why HSAs Matter for Tax Planning in 2026

For those unfamiliar, Health Savings Accounts offer the most tax-advantaged structure available:

  1. Contributions are tax-deductible (or pre-tax via payroll)
  2. Growth is tax-deferred (no tax on investment gains)
  3. Withdrawals are tax-free for qualified medical expenses

2026 contribution limits:

  • Individual coverage: $4,400
  • Family coverage: $8,750
  • Age 55+ catch-up: $1,000

The Tax Compliance Challenge

Here’s where clients get into trouble: the IRS can audit your HSA withdrawals for up to 7 years after filing. If you can’t prove an expense was qualified, you face:

  • 20% penalty on the distribution
  • Income tax on the amount
  • Potential additional penalties for negligence

The problem? Most people don’t maintain adequate documentation.

Beancount as Your Audit Defense System

This is where plain text accounting shines. Every transaction is documented, version-controlled, and linked to source documents.

My recommended metadata structure:

For every medical expense you plan to claim against HSA:

Qualified Expense Categories (IRS Pub 502)

What qualifies for HSA withdrawal? More than most people realize:

Medical & Dental:

  • Doctor visits, copays, deductibles
  • Prescriptions (WITH doctor’s note for OTC as of 2020)
  • Dental cleanings, fillings, orthodontics
  • Vision exams, glasses, contact lenses

Expanded in Recent Years:

  • Menstrual care products (2020 CARES Act)
  • Over-the-counter medications WITHOUT prescription (2020)
  • Telehealth visits
  • COVID-19 testing and PPE (temporary but extended)

Often Missed:

  • Mileage to/from medical appointments ($0.21/mile for 2026)
  • Lodging for medical travel (up to $50/night per person)
  • Long-term care insurance premiums (age-based limits)
  • Qualified long-term care services

NOT Qualified:

  • Cosmetic procedures (unless medically necessary)
  • Over-the-counter supplements (unless prescribed)
  • Health club dues (unless specific medical need)
  • General health expenses (fitness trackers, healthy food)

The “Stealth Retirement Account” Strategy

Some clients pay medical expenses out-of-pocket and let their HSA grow tax-free for decades. This works because:

  • No time limit on reimbursement
  • After age 65, can withdraw for any purpose (penalty-free, but taxed as income if non-medical)

But this requires meticulous record-keeping. The burden of proof is on the taxpayer.

Beancount Account Structure for Tax Compliance

I recommend this to clients:

The account tracks your “reimbursement bank” - expenses you’ve paid that are eligible for tax-free HSA withdrawal.

Document Retention Requirements

Minimum 7 years for:

  • Receipts showing date, provider, service, amount paid
  • EOBs (Explanation of Benefits) from insurance
  • Prescriptions or doctor’s notes (for OTC items)
  • Provider statements
  • Payment confirmations

Store digitally: Paper fades. Use cloud storage (encrypted) or Git LFS with Beancount metadata links.

Common Tax Mistakes to Avoid

  1. Contributing while not HSA-eligible (e.g., enrolled in non-HDHP after job change)
  2. Contributing while on Medicare (Part A enrollment ends HSA eligibility)
  3. Missing the pro-rata calculation (if you weren’t HDHP-covered for full year)
  4. Forgetting employer contributions count toward limits
  5. Claiming cosmetic procedures (unless medically necessary with documentation)

Questions for the Community

How are others handling:

  • Receipt digitization workflows?
  • Metadata tagging for audit readiness?
  • Queries to calculate reimbursable balance?
  • Tracking qualified vs non-qualified expenses?

For those using Beancount professionally, are you advising clients to adopt plain text accounting for HSA tracking?

The transparency and audit trail make it ideal for tax compliance, but the learning curve is real.

What’s your experience?

Excellent breakdown of the tax compliance side, @tax_tina! As a CPA who’s helped several clients implement HSA strategies, I want to add the accounting methodology perspective.

The Double-Entry Challenge

One of the trickiest parts about tracking HSAs in Beancount is properly representing the “pay now, reimburse later” strategy without creating accounting confusion.

The problem: When you pay a medical expense out-of-pocket but plan to claim it against your HSA later, you’re creating a real asset (the right to tax-free reimbursement), but it’s not reflected in your HSA account balance yet.

My recommended approach:

Assets:HSA:Fidelity:Cash
Assets:HSA:Fidelity:Investments:TotalMarket
Assets:HSA:ReimbursementBank      ; Tracks unclaimed reimbursements
Expenses:Medical:Healthcare
Expenses:Medical:Dental
Expenses:Medical:Prescriptions
Income:Salary:HSAContribution
Income:Employer:HSAContribution
Equity:HSA:TrackingOffset         ; Balances the reimbursement tracking

When you pay a qualified medical expense:

2026-03-27 * "Dr. Chen - Annual Physical"
  Expenses:Medical:Healthcare         350.00 USD
    receipt: "receipts/2026-03-27-dr-chen.pdf"
    provider: "Dr. Sarah Chen"
    service: "Annual preventive care exam"
    hsa-qualified: TRUE
    reimbursed: FALSE
  Assets:Checking                    -350.00 USD

2026-03-27 * "Track HSA reimbursement eligibility"
  Assets:HSA:ReimbursementBank        350.00 USD
    linked-expense: "2026-03-27 Dr. Chen"
  Equity:HSA:TrackingOffset          -350.00 USD

When you eventually claim the reimbursement (could be years later):

2045-06-15 * "HSA Reimbursement - 2026 Medical Expenses"
  Assets:HSA:Fidelity:Cash           -350.00 USD
  Assets:Checking                     350.00 USD
    reimbursement-for: "2026-03-27 Dr. Chen"

2045-06-15 * "Clear reimbursement bank entry"
  Equity:HSA:TrackingOffset           350.00 USD
  Assets:HSA:ReimbursementBank       -350.00 USD

Client Success Story

I have a client couple who started this strategy in 2016. They’re now at:

  • HSA balance: $87,000 (invested in index funds)
  • Unreimbursed qualified expenses: $23,000
  • Effective “tax-free emergency fund”: $23,000

They can withdraw up to $23,000 from their HSA tax-free and penalty-free at any time by claiming those past expenses. Meanwhile, the HSA continues growing tax-deferred.

Balance Assertions Are Critical

Because you’re tracking the reimbursement bank separately from your HSA provider’s balance, balance assertions prevent drift:

2026-03-31 balance Assets:HSA:Fidelity:Cash  2350.00 USD
2026-03-31 balance Assets:HSA:Fidelity:Investments:TotalMarket  12500.00 USD

Monthly reconciliation with your HSA provider statement catches any discrepancies.

The Common Mistake I See

Not investing HSA funds. Many clients leave their entire HSA balance in the cash account earning 0.01% interest. They’re missing the point of the “stealth retirement account” strategy.

Once you have 6-12 months of your deductible in cash, invest the rest. Treat it like your 401(k) or IRA.

Cost Basis Tracking

For investment transactions, track cost basis carefully:

2026-03-15 * "Invest HSA cash into VTSAX"
  Assets:HSA:Fidelity:Investments:VTSAX  25.00 VTSAX {100.00 USD}
  Assets:HSA:Fidelity:Cash             -2500.00 USD

2026-12-31 * "Mark to market - VTSAX price"
  Assets:HSA:Fidelity:Investments:VTSAX  0 VTSAX {110.00 USD}

Your HSA provider’s cost basis tracking is often wrong (especially if you transferred from another provider). Beancount lets you maintain the truth.

Query for Reimbursable Balance

Want to know how much you can withdraw tax-free? Query your reimbursement bank:

bean-query ledger.beancount "SELECT sum(position) WHERE account ~ 'Assets:HSA:ReimbursementBank'"

Questions for You

Tina, how do you advise clients on the timing of reimbursements? Is there any tax advantage to claiming sooner vs later (aside from the obvious growth advantage of leaving funds invested)?

Also, for the community: Anyone tracking employer vs employee contributions separately? It matters for tax reporting (Form 8889), but I’m not sure if the granularity is worth the complexity.