The general rule is: your report all your income on your home state return, even the income earned out of state. You file a non-resident state return for the state you worked in and pay tax to that state. Your home state will give you a credit, or partial credit, for what you paid the non-resident state. You file a MA full year resident return and calculate tax on ALL your income. MA will give you a credit, or partial credit, for any tax you pay to NH.
When you worked in a state without an income tax (e.g. New Hampshire, Texas or Florida), there will be no credit, since there was no work state tax. In other words, having worked in a state without an income tax does not get you out of paying state tax on that income, to your home state. Since NH does not have an income tax, you do not have a non-resident return to file. But you still have to pay tax on that income to your home state.
This is not a MA thing. It works the same in all states.