I am on H1 B visa since Oct 1, 2017. Last year, I was on F1 OPT. I am filing a Married filing jointly with my wife (is on H4 without any income). I am planning to fill in Form 4868 for extension and pay the necessary amt. After I meet the substantial presence test, say by May end, I will file form 1040 as Resident Alien. Is this the right thing to do? Or should I file taxes as a Non resident like I did last year? If I have both the options, which is the best?
In summary, yes, filing as a resident alien and married filing jointly often is the right and the sensible thing to do, and will likely minimize your tax liability. As usual with taxes, it is the best to calculate your liability using different methods, and pick the best.
Going in more details, tax residency status in this situation works in stages.
Since you arrived on October 1st, you do not meet substantial presence test as of the end of 2017. Thus, without making any elections, you would file as a non-resident alien.
Once you meet substantial presence test, which should happen in May 2018, your tax residency automatically propagates back in time to the beginning of 2018, but not into 2017. Thus, you still remain a non-resident alien for the entirety of 2017.
Once you have actually become a resident alien, you can make an election, referred to as the first year choice, to further propagate you residency back in time to the date of your arrival. That would make you a dual-status resident alien - non-resident alien before October 1, and resident alien after October 1. Your spouse is eligible for the same choice.
There is another election which is only available to married people under 26 USC paragraph 6013(h). Since both you and your spouse were non-resident aliens at the beginning of 2017, and resident aliens at the end of 2017 (due to both of you making the first year choice), you can elect to be treated as resident aliens for the entirety of 2017.
While everyone's situation is unique, and, like with many other things related to finances and taxes, there is no "one size fits all" answer, under a wide range of circumstances, electing to be treated as a resident alien in 2017 has numerous advantages:
Non-resident aliens and dual-status aliens are not eligible to use the standard deduction. They are thus forced to itemize their deductions.
The list of itemized deductions available to them is greatly limited. About the only thing they can deduct is state taxes. Chances are your state income tax was not very big, since you only worked 3 months in 2017. Claiming tax residency for the entirety of 2017 is thus a huge advantage.
Only resident aliens are eligible to file as married filing jointly. That often reduces tax liability - especially in situations where only one of the two spouses has income, so this turns into another substantial tax break.
There are, however, few things to keep in mind:
As a resident alien, you and your spouse would need to report your worldwide income. There is foreign earned income exclusion and foreign tax credit options available, due to which your tax liability will likely not increase much.
In case your spouse does not have SSN, you would need to apply for ITIN. This means you cannot e-file. Processing time will be longer than normal, too.
Don't forget about your state taxes, both extension, and filing as a partial-year resident of your state. Note that state tax law may not have a concept of tax residency comparable to the federal law, so this would need to be treated accordingly.