Skip to content

Fix tax_unit_itemizes tied-federal-tax fallback (#8210)#8213

Draft
PavelMakarchuk wants to merge 1 commit intomainfrom
fix-tax-unit-itemizes-tied-fallback
Draft

Fix tax_unit_itemizes tied-federal-tax fallback (#8210)#8213
PavelMakarchuk wants to merge 1 commit intomainfrom
fix-tax-unit-itemizes-tied-fallback

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

Closes #8210. Supersedes #8209.

Bug

When tax_liability_if_itemizing == tax_liability_if_not_itemizing (common at low/moderate incomes where refundable EITC + ACTC absorb any federal-tax difference between the two branches), tax_unit_itemizes falls back to:

state_standard_deduction < state_itemized_deductions

These helpers have asymmetric state coverage:

  • state_standard_deduction.py lists 8 states (CT, ID, MO, ND, NM, SC, UT, CO) that adopt the federal standard deduction.
  • state_itemized_deductions.py lists only 5 states (CT, GA, ND, SC, UT) for federal itemized. For CO/ID/MO/NM/VT/LA/etc., it sums state-specific line items, which for many states is $0.

For a CO joint filer with $50k of itemizable expenses and tied federal tax: state_standard_deduction = $31,500, state_itemized_deductions = $0, fallback returns False → don't itemize. TaxAct/TAXSIM both itemize.

Downstream effects

State TAXSIM ticket Mechanism
CO #870 CO taxable income = federal taxable income; standard-fed gives wrong CO tax
VT #869 vt_cdcc = 0.72 × capped_cdcc; capped_cdcc depends on federal tax → cascades
LA #854 Same mechanism via capped_cdcc
NJ #865, DE #850, etc. various Likely same root cause; pending triage

Fix

When federal tax is tied, fall back to the federal-level deduction comparison (standard_deduction vs itemized_taxable_income_deductions). This matches:

  • The non-branching path already in this file.
  • The IRS / TaxAct / TAXSIM-comparison-mode default of itemizing whenever itemized > standard at face value.

Daniel Feenberg confirmed in the issue that TAXSIM's PE-comparison mode uses this naive rule.

Note on the helper variables

state_standard_deduction and state_itemized_deductions remain in the codebase. They map to TAXSIM v34 ("Standard Deduction") and v35 ("Itemized Deductions") outputs in policyengine-taxsim's variable_mappings.yaml. tax_unit_itemizes simply no longer reads them internally.

Tests

  • 7 unit tests in tax_unit_itemizes.yaml — tied-tax cases retargeted to federal-level inputs.
  • me_deductions.yaml — tied-tax case retargeted (same input pattern).
  • CO integration (new): 2025 joint filer with $30k property tax + $20k mortgage, asserts tax_unit_itemizes: true. Locks in TAXSIM MA income tax docs are broken #870 fix.
  • VT integration (new): 2025 joint filer with property tax + mortgage, asserts tax_unit_itemizes: true and vt_cdcc: 0. Locks in TAXSIM Create issues for each program x state combination with the GitHub API #869 fix.
  • All 13,825 state-level tests pass; 817 federal IRS tests pass.

Residual gaps to TaxAct (out of scope)

  • CO income tax is ~$65 short of TaxAct's -$4,397 (CO add-back issue).
  • VT income tax is ~$1 short of -$3,045 (rounding).

Both are pre-existing state-model issues — the fix gets us from "very wrong" to "within rounding/state-add-back precision."

Test plan

  • make format clean
  • All directly-affected tests pass locally
  • Full state-level test suite passes (13,825 / 13,826 → 13,826 after ME fix)
  • Full IRS test suite passes (817)
  • CI green

🤖 Generated with Claude Code

Closes #8210. Supersedes #8209.

When tax_liability_if_itemizing == tax_liability_if_not_itemizing — common
at low/moderate incomes where refundable EITC + ACTC absorb any federal-tax
difference between the two branches — tax_unit_itemizes was falling back to:

    state_standard_deduction < state_itemized_deductions

This used two helpers with asymmetric coverage:
- state_standard_deduction lists 8 states (incl. CO, ID, MO, NM) that adopt
  the federal standard deduction
- state_itemized_deductions only lists 5 states (CT, GA, ND, SC, UT) that
  adopt federal itemized deductions; for CO/ID/MO/NM/VT/LA/etc. it sums
  state-specific itemized line items, which for many states is $0

For a CO joint filer with $50k of itemizable expenses and tied federal tax,
the fallback compared $31,500 < $0 → False → don't itemize. TaxAct/TAXSIM
itemize. Same mechanism caused VT/LA TAXSIM diffs via dependent CDCC.

Fix: when federal tax is tied, fall back to the federal-level deduction
comparison (standard_deduction vs itemized_taxable_income_deductions),
matching the non-branching path and the IRS / TaxAct / TAXSIM-comparison
default.

Note: state_standard_deduction and state_itemized_deductions remain in the
codebase — they map to TAXSIM v34/v35 outputs in policyengine-taxsim's
variable_mappings.yaml. tax_unit_itemizes simply no longer reads them
internally.

Tests:
- 7 unit tests in tax_unit_itemizes.yaml — updated tied-tax cases to use
  federal-level inputs
- ME me_deductions.yaml — updated tied-tax case (same input pattern)
- CO integration: new 2025 joint filer with property tax + mortgage,
  itemizes (TAXSIM #870)
- VT integration: new 2025 joint filer scenario, itemizes (TAXSIM #869)
- All 13,825 state-level tests pass; 817 federal IRS tests pass.

Residual numeric gaps to TaxAct/TAXSIM (CO ~$65 on income tax, VT ~$1)
are pre-existing state-model issues outside this PR's scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d55cd4f) to head (9c44328).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8213   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         1    -1     
  Lines           35        18   -17     
  Branches         0         1    +1     
=========================================
- Hits            35        18   -17     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

tax_unit_itemizes fallback misbehaves when federal tax is tied — picks standard against TaxAct/TAXSIM behavior

1 participant