pk
Level 15
Level 15

Deductions & credits

Let us go back a little --- when did you enter USA with H-1B?
My understanding would be that a Non-Resident Alien, on leaving USA, is effectively surrendering the visa and therefore not any longer valid. Also the income is taxed  based on residence i.e. Canada will tax all incomes based on whwre the work is done i.e. irrespective of the ultimate source of income, Canada will tax you on your world income -- the fact that it is coming from a US source is not important. Therefore I am not sure why you are choosing to file a USA 1040/1040-NR because  from US perspective active income ( wages )   must be for work done in the USA --- if an USA company has a remote worker  ( a Non-Resident Alien ) in South Africa -- he/she has no USA sourced / connected  income in the USA and tgherefore does not pay any US taxes.
Also for tax purposes it is the  Tax treaty  between  US and Canada that is in force  and generally not NAFTA/USAMC treaty.
Suggest you consult a Canadian Tax professional