Moved for just 5 months: trouble filing as resident and non-resident

I lived in Massachusetts from January - February 2021, and moved to Rhode Island when I got married in March. We lived there until the end of July, when we moved back to Massachusetts from August until the end of the year. (This means I spent 5 months in RI and 7 in MA during 2021, and mistakenly thought I'd skip the tax headache because MA was my primary residence.) I had the same job the whole year, which was based in MA.

 

Looking at other threads, I'm seeing I may have to file

  • as non-resident of MA (5 months)
  • as resident of MA (7 months)
  • as RI resident (5 months)
  • and possibly also with MA as full-time worker / telecommuter (or is that included in my R/NonR filing)?

 

...and figure out how to file jointly with my spouse ðŸ˜© If I'm correct, how many returns is this?? Should I ditch the self-filing and just get someone more experienced to deal with it for me?