I came to the US in 2007 on an H-4. Then in 2017 I switched to an F-1 visa. Am I a resident for tax purposes? I keep reading that on an F-1 you are "exempt" from the substantial presence test for 5 years, but I believe I already was a resident before switching to F-1, so did I undo it? Still really confused on this, would love any help here in determining if I should file 1040 or the 1040nr.
Since you are not a permanent resident, you are a resident alien for a year if you pass the Substantial Presence Test for the year. You are an "exempt individual" (days not counted in the SPT) as a student for your days in F1 status in a given year, if you have not been an "exempt individual" for any part of 5 previous years.
So basically, if you haven't been on F or J status before 2017, then you will be an "exempt individual" for your days in F1 status in 2017. Not counting the days in F1 in 2017 may or may not be enough to make you fail the SPT for 2017 (it depends on how much of 2017 you were on H4 status, and how much you were in the US in 2015 and 2016, since the SPT formula also considers days in the previous 2 years). For 2018, you should be a nonresident alien since all of your days in the US in 2018 are as an "exempt individual", so you shouldn't pass the SPT for 2018.