Working from home during the pandemic could lead to a big hit for New York's budget if the U.S. Supreme Court rules in favor of New Hampshire in a simmering tax dispute with Massachusetts. 

At issue is a lawsuit being advanced this week brought by New Hampshire to block Massachusetts from taxing its residents who have worked remotely for Massachusetts-based companies due to the COVID-19 pandemic. 

A favorable ruling for New Hampshire could be precedent setting, and impact states that levy an income tax on out-of-state workers employed by in-state companies and commute over state lines, a Moody's report on Thursday found. 

And while Massachusetts would take a hit of about 4% of its tax revenue, New York could be in line for an even larger loss if a ruling is applied broadly to other states.

New York state's reliance on non-resident income tax revenue accounts for 15% of the personal income tax and 7% of state operating revenue for the fiscal year that ended in 2018 -- not an insignificant percentage given the state's dire fiscal needs made worse by the pandemic and resulting economic recession. 

All told, New York collected $7 billion in tax revenue that year from non-resident taxpayers living in other states. 

"The loss of even a portion of that revenue would compound the state's challenges as it faces large budget gaps because of the coronavirus effects and a fiscal imbalance in its Medicaid program," Moody's found.

Working from home has, of course, already cost the state heavily over the last 10 months. Reduced commuting has meant fewer people paying sales tax to gas up their cars or paying train fare. Sales tax on the local level and mass transit revenue has plummeted as a result.

New York is seeking billions of dollars in federal aid to shore up its revenue after the pandemic closed businesses and limited public gatherings, sending the state's economy into a deep freeze.

Commuters in states lke Connecticut and New Jersey would be among the main beneficiaries, Moody's found, if the court ruled in favor of non-resident workers.