I'm not sure if I am considered a resident or non-resident

I'm a non-US citizen and lived abroad from 2013-2020. During that time, I had a greencard that expired in 2017 but I filed the form I-407 (to abandon status) in 2020 because I didn't realized until 2020 that I had to actually abandon my permanent resident status. 

 

1) As a non-US citizen, for tax filing purposes, was I required to file tax returns after my greencard expired (in 2017)? (i.e., for tax purposes, was I considered a permanent resident up until I actually abandoned my permanent resident status in 2020)?

 

2) I abandoned my greencard in mid-2020 and returned to the US as a non-resident alien in late 2020. I filed my 2020 taxes as a non-resident alien (Form 1040NR) because I thought to go off my current status as a non-resident alien. Is that correct or should I have filed a regular Form 1040 (depending on my answer to Q1)?

 

Apologies for the long post, and thank you in advance to anyone who can provide any insight.