You only need to pay tax on any income you earned while working in MA. The portion of your work that you performed while working at home in NH is considered NH source income. If you had any days that you had to go to MA for meetings, etc, you would need to prorate your income and pay MA tax on the MA workdays.
You will need to file a MA nonresident state return and report any MA workdays (if any). Most if not all of your taxes should be refunded.