Skip to content

Fix Pennsylvania taxable income for alimony and 401(k)/403(b) deferrals - #11162

Merged
hua7450 merged 2 commits into
mainfrom
pa-income-tax-alimony-401k
Nov 20, 2026
Merged

hua7450 merged 2 commits into
mainfrom
pa-income-tax-alimony-401k

Conversation

@DTrim99

@DTrim99 DTrim99 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Part of #10812 (state credit income audit).

What was wrong

Two bugs in pa_total_taxable_income (PA-40 line 9). It starts from federal gross income, adds pa_other_additions and subtracts the list gov.states.pa.tax.income.nontaxable_income_sources. Both bugs change Pennsylvania income tax itself, and they also flow into Tax Forgiveness eligibility income (Schedule SP line 1) and the use tax estimate.

  1. Alimony. The list did not include taxable_alimony_income, so alimony under a pre-2019 divorce stayed in PA taxable income. divorce_year defaults to 2010, so this hit all modeled alimony. Pennsylvania does not tax alimony: the 2025 PA-40 instructions list "Alimony" under "Income not taxable for PA PIT purposes" (2025 PA-40 IN, page 8). Schedule SP line 3 then added alimony_income on top, so eligibility income counted pre-2019 alimony twice.
  2. Elective deferrals. The model starts from irs_employment_income, which is wages minus pre_tax_contributions, so traditional 401(k) and 403(b) deferrals never counted. Pennsylvania taxes them:
    • 2025 PA-40 IN, Line 1a, page 12: "The contributions you make to your employer's sponsored retirement plan are PA-taxable compensation, even if your contributions are not taxable for federal purposes or included in the state wages shown on your W-2."
    • 61 Pa. Code 101.6(c)(8)(ii)(B): contributions an employee makes to a plan "whether through payroll deduction, a salary reduction agreement or otherwise, are not excludable from his income".
    • PA PIT Guide, Gross Compensation (DSM-12 08-2025), page 51: elective contributions to a "401(k) Plan or 403(b) plan or other program ... are not excludable from the employee's Pennsylvania income".

What changes

  • nontaxable_income_sources.yaml gains taxable_alimony_income, with the 2025 PA-40 IN page 8 reference. Only the part federal gross income holds comes off, so alimony under a 2019-or-later divorce is untouched.
  • New list taxable_elective_deferral_sources.yaml, holding traditional_401k_contributions and traditional_403b_contributions, with the three sources above.
  • New person variable pa_taxable_elective_deferrals sums that list. It adds back no more than federal wages actually left out (employment_income - irs_employment_income), because federal wages are floored at zero.
  • pa_total_taxable_income adds the head's and spouse's pa_taxable_elective_deferrals, the same way it already subtracts only their nontaxable amounts. A dependent's deferrals stay off the filer's return, as their wages do.
  • pa_tax_forgiveness_eligible_share approximates each spouse's own PA taxable income. It now adds the same deferrals, so the per-spouse split matches the new total.
  • pa_other_additions documentation now says the deferrals are already included, so users don't enter them twice.

Pre-tax items I left out, because no PA source I read says they are taxable:

  • Pre-tax health premiums. 72 P.S. 7301(d)(vi), quoted in the PIT Guide (Gross Compensation, pages 32-33), excludes payments under a section 125 cafeteria plan for nondiscriminatory hospitalization, sickness, disability or death coverage.
  • Dependent care assistance. The 2025 PA-40 IN, page 9, lists amounts "excludable under 26 U.S.C. § 129" among income not taxable.
  • HSA payroll contributions. The 2025 PA-40 IN, page 20, says Pennsylvania "follows federal rules" for HSA contributions. I found no PA source calling payroll HSA contributions taxable compensation.
  • 457(b) and Thrift Savings Plan deferrals. Pennsylvania taxes funded 457(b) and TSP deferrals too (PIT Guide pages 6 and 51), but no model input holds them, so the list names only 401(k) and 403(b).

Who is affected

  • Pennsylvania income tax rises for filers (head or spouse) with traditional 401(k) or 403(b) deferrals, by 3.07% of the deferral. For example, $6,000 of 401(k) deferrals on $60,000 of wages raises PA tax from $1,657.80 to $1,842. Tax Forgiveness eligibility income rises by the same amount, so some of these filers also get less forgiveness.
  • Pennsylvania income tax falls for alimony recipients whose divorce was before 2019, by 3.07% of the alimony. For example, $12,000 of alimony on $40,000 of wages lowers PA tax from $1,596.40 to $1,228. Their eligibility income falls by the alimony that was double counted, so some also get more forgiveness.
  • Roth 401(k) deferrals, alimony under 2019-or-later divorces and dependents' deferrals don't change.

Retirement distributions (reported, not changed)

Contributions Pennsylvania taxed going in become basis in the plan. The model handles distributions this way:

  • Once the recipient reaches the 59.5 proxy age (retirement_age_threshold), pa_nontaxable_pension_income and pa_nontaxable_retirement_distributions exclude the whole federally taxable pension, IRA, 401(k), 403(b), SEP and Keogh distribution. Basis doesn't matter then.
  • Below that age, the model taxes the full federally taxable amount. Pennsylvania taxes only the part above previously taxed contributions, using the cost recovery method (61 Pa. Code 101.6(c)(8)(iii); 2025 PA-40 IN, pages 12-13). Federal basis in pre-tax 401(k) and 403(b) deferrals is zero, so for early distributions the model overstates PA income by up to the PA basis. No input holds that basis. This PR doesn't change it.

Tests

Moved from #10812 (pa_eligibility_income_audit.yaml) into taxable_income/pa_total_taxable_income.yaml, since pa_total_taxable_income is the variable they fix:

  • "Pre-2019 alimony counts once": expects pa_eligibility_income 8,000, and now also asserts pa_total_taxable_income: 5_000, as the review asked, to show the double count came from PA taxable income. Before this PR: 11,000 and 8,000.
  • "A 401(k) contribution is PA-taxable compensation": expects pa_total_taxable_income and pa_eligibility_income of 10,000, and now also asserts federal wages of 9,000 and the 1,000 add-back. Before this PR: 9,000.

Added in pa_total_taxable_income.yaml:

  • Alimony under a 2018 divorce: PA taxable income 40,000 and tax 1,228. Under a 2019 divorce: federal and PA income both 40,000, so nothing comes off twice. These are the two sides of the federal cutoff.
  • A $6,000 401(k) deferral on $60,000 of wages: PA taxable income 60,000 and tax 1,842.
  • A joint return with a 401(k) deferral, a 403(b) deferral and a Roth 401(k) deferral. PA taxable income is 90,000, because only the traditional deferrals come back.
  • Pre-tax health premiums stay excluded while the 401(k) deferral is added back: 47,000.
  • A deferral equal to the wages is added back in full (3,000). A deferral above the wages adds back only the wages (2,000).
  • A dependent's deferral stays off the filer's PA taxable income.

Added in forgiveness/pa_tax_forgiveness_amount.yaml:

  • A joint return where the claimable head has a 401(k) deferral. The eligible share is 0.5 (3,000 / 6,000). Leaving the deferral out would give 0.6.

No existing expected values changed. No partner test failed.

Not in this PR

Other Pennsylvania gaps from the #10812 review, left for a later PA credits PR:

  • Schedule SP eligibility income (pa_eligibility_income) misses interest on U.S. obligations (line 2), life insurance proceeds (line 4), nontaxable scholarships (line 9) and cash from people outside the household (line 10). These are the other four cases in pa_eligibility_income_audit.yaml.
  • Property Tax/Rent Rebate income (pa_property_tax_or_rent_rebate_income) has four gaps:
    • Pre-2019 alimony counts twice: it's already in AGI, and line 11 adds it again.
    • Gross wages should come before 401(k) deferrals.
    • Cash public assistance isn't counted.
    • Line 10 business, profession and farm netting isn't modeled.
  • The cost-recovery basis for early retirement distributions, described above.

Tested on Modal: run w1-pa-a, 240/240 passed: 238 YAML test files (every Pennsylvania test, all 144 partner files, and the other state, household and contrib files that read PA income tax) and 2 pytest files (test_source_conflicts.py, test_claimable_filer_nj_pa_invariants.py). The runner also received the two changed parameter files, which hold no tests and failed only for that reason.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8999568) to head (35db7d5).
⚠️ Report is 238 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main    #11162   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         4    +3     
  Lines           24        73   +49     
=========================================
+ Hits            24        73   +49     
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 Harness.
📢 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.

@DTrim99
DTrim99 requested a review from hua7450 November 19, 2026 22:40

@hua7450 hua7450 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, David. Both fixes check out. Pennsylvania does not tax alimony ("Alimony" under "Income not taxable for PA PIT purposes", 2025 PA-40 IN p. 8), and with taxable_alimony_income subtracted, Schedule SP eligibility income counts alimony exactly once for pre-2019 and post-2018 divorces (8,000 in your case, 11,000 on main). Employee deferrals to 401(k) and 403(b) plans are PA compensation under 61 Pa. Code 101.6(c)(8)(ii)(B) and the Line 1a instruction, while health premiums and HSA payroll contributions are correctly left out. The head and spouse handling is symmetric, the per-spouse forgiveness share matches the new line 9, and all 11 new expected values derive by hand. One small fix before I approve.

Before merge

  1. pa_taxable_elective_deferrals can go negative. min_(deferrals, employment_income - federal_wages) has no zero floor, so a negative employment_income gives a negative add-back even with no deferrals. Wages of -1,000 plus 5,000 of interest now give PA taxable income of 4,000; main gives 5,000. max_(0, employment_income - (pre_tax_contributions - deferrals)) - federal_wages floors it, matches your ten cases, and also fixes the mixed case where other pre-tax items push federal wages to zero (wages 10,000, 401(k) 8,000, premiums 4,000: the current cap adds back 8,000, where PA compensation is 6,000). Please add one negative-wage case.

Optional

  • Dependent care in 2021 and 2022. 61 Pa. Code 101.6(i)(2) says coverage under a dependent care plan "would constitute compensation", and Act 34 of 2023 excluded it only from tax year 2023. The new list starts in 2021 and the PR body rules dependent care out on the 2025 instructions alone. The gap is on main already; either a dated entry for 2021-2022 or a line saying those years are left out would cover it. The PIT Guide (08-2025, p. 32) and the unamended regulation still call it taxable, so it is also a candidate for source_conflicts/candidates.yaml.
  • Withholding (follow-up). pa_withheld_income_tax still follows federal AGI, so it now differs from PA tax on exactly the two fixed items: 1,657.80 withheld against 1,842 of tax in your 60,000 / 6,000 case. The federal SALT deduction and paycheck withholdings do not see the fix.
  • Schedule SP line 10 counts employee cafeteria-plan payments for health coverage (2025 PA-40 IN p. 38), which pa_eligibility_income omits. It predates this PR; worth adding to the "Not in this PR" list.
  • Authority for the two items left out. 72 P.S. 7303(a.6) for HSA payroll contributions and Act 34 of 2023 for dependent care would be better citations than the instructions alone.
  • Tests. The 2019-divorce case does not assert pa_eligibility_income (52,000 by trace), which would pin "counted once" on the post-2018 side. The cases at lines 227 and 243 are the same deferral class, and those at 164 and 181 the same pre-2019 class. The three cap cases would sit better in a pa_taxable_elective_deferrals.yaml.

DTrim99 and others added 2 commits November 20, 2026 11:01
Pennsylvania does not tax alimony, so the part of it in federal gross
income now comes off PA taxable income. Pennsylvania taxes an employee's
traditional 401(k) and 403(b) deferrals as compensation, so they are now
added back to the federal wages that leave them out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compute the add-back as PA compensation (employment income less non-deferral
pre-tax deductions, floored at zero) minus federal wages, so negative wages
no longer produce a negative add-back and cafeteria-plan premiums are not
added back. Add tests for negative wages and premiums that zero out federal
wages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DTrim99
DTrim99 force-pushed the pa-income-tax-alimony-401k branch from e41c062 to 35db7d5 Compare November 20, 2026 16:03
@DTrim99

DTrim99 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, Ziming. Fixed in 35db7d5, rebased on main.

Fixed (your "Before merge" item)

  • Zero floor. pa_taxable_elective_deferrals now uses your formula, max_(0, employment_income - (pre_tax_contributions - deferrals)) - federal_wages, so the add-back can't go negative. It also handles the mixed case.

  • Two new cases in pa_total_taxable_income.yaml:

    • Wages of -1,000 plus 5,000 of interest: add-back 0, PA taxable income 5,000, tax 153.50.
    • Wages 10,000, 401(k) 8,000, premiums 4,000: add-back 6,000, PA taxable income 6,000, tax 184.20.

    Both fail under the old formula, giving -1,000 and 8,000.

  • All eight existing deferral cases keep their expected values. One comment that described the old formula was reworded.

Skipped (optional, not in this round): dependent care in 2021-2022, the withholding follow-up, Schedule SP line 10, citations for the two items left out, and test reorganization.

Verification: the PA income tax tests pass locally after the rebase (124/124). An independent check confirmed the formula and both new values by hand. Ruff is clean.

@DTrim99
DTrim99 requested a review from hua7450 November 20, 2026 16:04

@hua7450 hua7450 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, David. pa_taxable_elective_deferrals is now PA compensation, max_(0, employment_income - (pre_tax_contributions - deferrals)), less federal wages, so the add-back can't go negative and stops at what Pennsylvania counts when other pre-tax items push federal wages to zero. The two new cases pin both (negative wages give 5,000 of taxable income; 10,000 of wages with an 8,000 deferral and 4,000 of premiums add back 6,000). Comparing the PR's own diff before and after the rebase, those are the only changes. Approving.

@hua7450
hua7450 merged commit 222b769 into main Nov 20, 2026
40 checks passed
@hua7450
hua7450 deleted the pa-income-tax-alimony-401k branch November 20, 2026 17:25
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.

2 participants