Skip to content

Deduct Montana's 2021–2023 medical and long-term care insurance premiums in full (Itemized Deductions Schedule lines 2–3) - #9947

Draft
MaxGhenis wants to merge 38 commits into
mainfrom
fix-mt-medical-premiums-in-full
Draft

MaxGhenis wants to merge 38 commits into
mainfrom
fix-mt-medical-premiums-in-full

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9930. Stacked on #10055 (hub-owned; nets the self-employed health insurance deduction out of federal Schedule A premiums). Until #10055 merges, this diff also shows its changes. Merge #10055 first, then merge main into this branch. #9903, which this PR was first stacked on, has merged (51487d5).

Summary

For TY2021–2023, Montana's Itemized Deductions Schedule (Form 2 page 7) splits medical costs across three lines:

  • line 1 reduces medical and dental expenses other than insurance premiums by 7.5% of Montana AGI;
  • line 2 deducts medical insurance premiums in full;
  • line 3 deducts long-term care insurance premiums in full.

Lines 2 and 3 exclude premiums already deducted in Montana AGI. PolicyEngine floored everything together: mt_medical_expense_deduction_joint and mt_medical_expense_deduction_indiv put the premiums (including modeled Medicare Part B) under the 7.5% floor and left out long-term care premiums.

What the law and forms say

Former MCA § 15-30-2131(1) (MCA 2021; repealed effective January 1, 2024):

  • (1)(a) allows the IRC § 161 and § 211 items, which bring in the § 213 medical deduction and its floor. It excludes "(iii) premium payments for medical care as provided in subsection (1)(g)(i)" and "(iv) long-term care insurance premium payments as provided in subsection (1)(g)(ii)".
  • (1)(g) allows "the entire amount of premium payments made by the taxpayer, except premiums deducted in determining Montana adjusted gross income", for (i) medical care insurance as defined in 26 U.S.C. 213(d) and (ii) qualified long-term care insurance (26 U.S.C. 7702B(c)). The coverage must be for the taxpayer, dependents, parents and grandparents.

Form 2 page 7 (2022, PDF p. 7; 2021 and 2023 have the same lines):

  • line 2, "Medical insurance premiums not deducted elsewhere on your return";
  • line 3, "Long-term care insurance premiums not deducted elsewhere on your return";
  • neither line has a floor.

Form 2 instructions (2022, PDF pp. 32–33; 2021 PDF pp. 31–32 and 2023 PDF p. 36 say the same):

  • Line 1 excludes premiums claimed on lines 2 and 3.
  • Line 2 makes Medicare Part B and Part D premiums 100% deductible. To qualify, premiums cannot be:
    • paid through an HSA or a Montana medical care savings account;
    • paid pre-tax through an employer cafeteria plan;
    • deducted as the self-employed health insurance deduction (Schedule 1, line 17) or on the Montana Subtractions Schedule, line 11.
  • Line 3 deducts long-term care premiums "without regard to the federal limitation" when they were not deducted in determining Montana AGI. The 2021 instructions also exclude premiums claimed for the Elderly Care Credit (former MCA § 15-30-2366, repealed effective 2022).

26 U.S.C. 162(l)(2)(C) (govinfo) lets eligible long-term care premiums into the self-employed health insurance deduction. So line 3 must also net that deduction, not only line 2.

From 2024 the 2024 instructions (PDF p. 8) list the Itemized Deductions Schedule (and filing status 2a's schedules) as discontinued. Montana then takes federal itemized deductions, where premiums stay under the federal floor. That treatment is unchanged here.

Changes

  • mt_eligible_medical_insurance_premiums (new, person; line 2) = medical_expense_health_insurance_premiums − Exclude SE health insurance deductions from Schedule A medical expenses #10055's self_employed_health_insurance_ald_excluded_premiums (the person's self-employed deduction, capped at their premiums).
    • medical_expense_health_insurance_premiums includes modeled Medicare Part B.
    • It never reads pre_tax_health_insurance_premiums, a separate input that reduces wages through pre_tax_contributions. So pre-tax premiums stay off line 2.
  • mt_eligible_long_term_care_insurance_premiums (new, person; line 3) = max(0, long_term_health_insurance_premiums − the part of the person's self-employed deduction not used by line 2).
    • Lines 2 and 3 together equal max(0, premiums + long-term care premiums − deduction). The deduction is netted once, and the order of allocation doesn't change the total.
  • mt_medical_expense_deduction_joint:
    • 2021–2023 (state_specific_deduction_applies): line 1 = max(0, Σ other_medical_expenses − 7.5% × mt_agi_joint), plus Σ lines 2 and 3 over the return's members, held by the head.
    • It no longer reads itemized_medical_expenses in those years, so Exclude SE health insurance deductions from Schedule A medical expenses #10055's Schedule A exclusion and line 2 never both apply.
    • From 2024 it is the federal medical_expense_deduction, unchanged.
  • mt_medical_expense_deduction_indiv: the same three lines per spouse on their own mt_agi_indiv, while the schedule applies. If a reform allows separate filing after 2023 (enable_mt_mfss_2024_reform), it keeps Exclude SE health insurance deductions from Schedule A medical expenses #10055's treatment: premiums net of the self-employed deduction, under the floor with the other expenses.
  • Stack updates:
  • References use the official MCA 2021 page instead of the Justia URL, which returns 403.
  • Fixed the existing separate-filing case "Not head or spouse ineligible", which had set is_tax_unit_head_or_spouse: true.

Household effects (real runs: base = #10055 head ba2f3b8, this branch 595cd1e)

Household Montana medical deduction Montana income tax
2022 couple: wages $80k, $6k after-tax premiums, $3k other medical, $8k property tax $3,000 → $6,000 $3,278.68 → $3,076.18
2023 single, 70: $40k pension, Medicare Part B $1,978.80 + $3k Medigap, $2k other medical, $5k property tax $3,978.80 → $4,978.80 $511.35 → $445.31
2021 couple: wages $120k, $5k long-term care premiums, $6k property tax $0 → $5,000 $3,720.76 → $3,375.76
2022 self-employed single: Schedule C $50k, $6k premiums taken as the self-employed deduction $0 → $0 $1,511.70 → $1,511.70
2023 self-employed single: Schedule C $60k, $3k medical + $2k long-term care premiums in the self-employed deduction, $2k other medical $0 → $0 $2,076.24 → $2,076.24

All five itemize before and after. The two self-employed rows show the deduction netted once: #10055 already removes those premiums from the base, and lines 2–3 net them the same way, including the long-term care premiums. The base ran on policyengine-core 3.33.2 and the branch on 3.32.27 (lock). Script and outputs: ~/reviews/mt-medical-premiums-2026-10-06/household_examples.py, household_base_r2.json, household_pr_r2.json.

Microsim impact

No microsimulation was run, and none is reported. The change affects TY2021–2023 only. From 2024:

So 2024+ baseline microsimulation results are unaffected.

Tests

Pending: targeted files, one at a time, queued behind the shared heavy lock. This section will be filled in from the run.

Invariants

tests/unit/test_mt_medical_premium_deduction_invariants.py uses Hypothesis batches plus a seeded population of 120 returns, over 2021–2024. Each batch runs as one vectorized simulation that holds each return, a twin with higher premiums, and a twin without pre-tax premiums. The 7.5% rate comes from Form 2 line 1c. Montana AGI and the self-employed deduction are read from the model; they are inputs to the properties, not derived independently.

  1. Accounting (2021–2023).
    • Joint = max(0, other expenses − 7.5% × Montana AGI) + line 2 + line 3, held by the head.
    • Separate = the same per head and spouse on their own Montana AGI; dependents hold 0.
  2. Premium conservation, per person, against a closed form:
    • line 2 + line 3 = max(0, premiums + long-term care premiums − self-employed deduction), with premiums computed from the raw inputs (direct, decomposed, or with Medicare Part B);
    • line 2 = premiums − min(premiums, deduction);
    • supplied deductions (0–20,000, often above the premiums) are carried through.
  3. Bounds: lines 2 + 3 ≤ deduction ≤ lines 2 + 3 + other expenses.
  4. Slope of one: raising after-tax or long-term care premiums of people with no self-employed deduction raises the deduction by exactly the increase. Montana AGI is unchanged (asserted).
  5. Pre-tax premiums never change lines 2 or 3.
  6. Line 1 base = federal itemized_medical_expenses + Exclude SE health insurance deductions from Schedule A medical expenses #10055's itemized_medical_expenses_applied_exclusion − premiums. This fails if the federal aggregate gains a component.
  7. Differential: for single filers the joint and separate variants agree.
  8. From 2024: joint = federal medical_expense_deduction, and the separate variant is 0.

Non-vacuity (seeded population) checks that the population includes:

  • returns deducting premiums while line 1 is under the floor;
  • returns with line 1 positive too;
  • people whose self-employed deduction exceeds their medical premiums and reduces line 3;
  • single and joint returns.

Why Python: YAML can't generate populations or compare twin returns. Cost: pending (measured in the same run).

Not modeled (no PE inputs)

  • Premiums paid from an HSA or a Montana medical care savings account.
  • The Montana Subtractions Schedule line 11.
  • Part D premiums, beyond what a user puts in health_insurance_premiums.
  • The 2021-only exclusion for premiums claimed under the Elderly Care Credit, which PE doesn't model.
  • Dependents' medical expenses on returns filed separately on the same form. _indiv counts each spouse's own amounts, as before.
  • Who paid a dependent's premiums. Premium inputs use Exclude SE health insurance deductions from Schedule A medical expenses #10055's payer attribution, and line 2 counts every member's premiums as the federal aggregate does.

Follow-ups (outside this PR)

  • The self-employed health insurance deduction's earnings limit: PE caps it at gross profit, but § 162(l)(2)(A) uses § 401(c) earned income, after half of SE tax. This came from the round 1 review; the YAML here supplies the deduction rather than deriving it.
  • § 213(d)(10) eligible long-term care premiums are not in federal itemized_medical_expenses.

Reviews

  • Round 1 (Opus, at 664331b): REQUEST CHANGES, five P2s and two P3s, answered above.
  • Round 2: GPT-6.1 Sol delta review at 595cd1e in progress.

axiom: TheAxiomFoundation/rulespec-us#1528 queued (former MCA § 15-30-2131(1)(g), Itemized Deductions Schedule lines 2–3, TY2021–2023; the signed encoder is blocked because the pinned corpus has § 15-30-2131 only as a repeal marker and no 2021–2023 Form 2 scope; sibling of #1520, which covers line 1)

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits October 6, 2026 11:06
…eturn's Montana AGI

The 2021-2023 Form 2 Itemized Deductions Schedule (line 1b) and Standard
Deduction Worksheet (line 1) take Montana AGI from page 1, line 14. Single,
head of household and joint returns report that line in one column, so a
joint return pools both spouses' income before flooring at zero. Both
joint-path variables instead summed each spouse's mt_agi_indiv, which floors
each spouse at zero first, so a spouse's loss never offset the other's
income. They now use mt_agi_joint.

From 2024 mt_agi_indiv is switched off (Montana repealed filing separately
on the same form), so the joint medical floor fell to zero and the full
medical expense was deducted. From 2024 Form 2 line 2 takes federal
itemized deductions (Worksheet A), so the variable now carries the federal
medical expense deduction (7.5% of federal AGI). A new parameter,
gov.states.mt.tax.income.deductions.itemized.state_specific_deduction_applies,
marks the switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in full

For TY2021-2023 the Form 2 Itemized Deductions Schedule floors only line 1,
medical and dental expenses other than premiums, at 7.5% of Montana AGI.
Line 2 deducts medical insurance premiums in full, except premiums already
deducted in Montana AGI (the self-employed health insurance deduction) and
pre-tax premiums; line 3 deducts long-term care insurance premiums in full
(former MCA 15-30-2131(1)(a)(iii)-(iv) and (1)(g)).

- New mt_eligible_medical_insurance_premiums (person): federal medical
  expense premiums, including Medicare Part B, less the person's
  self-employed health insurance deduction.
- mt_medical_expense_deduction_joint (2021-2023) and _indiv: line 1 floored
  on Montana AGI, plus lines 2 and 3 in full. From 2024 the joint variant
  keeps the federal medical expense deduction.

Fixes #9930. Stacked on #9903.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 2 commits October 6, 2026 18:41
The 2021-2023 property now expects max(0, other expenses - 7.5% of Montana
AGI) plus line 2 and 3 premiums. The grid's age-70 single filers carry
modeled Medicare Part B premiums, which the schedule deducts in full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 11 commits October 10, 2026 18:01
…iums-in-full

# Conflicts:
#	policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_medical_expense_deduction_joint.yaml
#	policyengine_us/tests/unit/test_mt_joint_agi_deductions_properties.py
#	policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_joint.py
…nto fix-mt-medical-premiums-in-full

# Conflicts:
#	policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_medical_expense_deduction_indiv.yaml
#	policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_medical_expense_deduction_joint.yaml
#	policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_indiv.py
- Line 2 reuses #10055's per-person excluded premiums; the new line 3
  variable nets the remainder of the self-employed deduction from
  long-term care premiums (26 U.S.C. 162(l)(2)(C) lets those premiums
  into that deduction).
- The separate-filing variant applies lines 2 and 3 only while the
  Itemized Deductions Schedule applies; a reform that allows separate
  filing after 2023 keeps premiums under the floor.
- Tests: supply the self-employed deduction where its earnings limit
  matters, a below-floor dependent case, #10055's Montana cases moved to
  lines 1-3, and invariants for premium conservation and #10055's
  applied exclusion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduct Montana 2021–2023 medical and long-term care insurance premiums in full (Itemized Deductions Schedule lines 2–3)

1 participant