Welcome to AF.
It wouldnt work due to the year changes, 02 vs 97 electrical is different, and the trans wouldnt bolt up right to your 3.1 from the newr 2.4, then you have all the mounting issues and the 4t40e is smaller with smaller axles.
The 4t40e is a weaker version of the 4t60e series.
The 4t60e is a much better trans and readily available for about the same cost.
Grand ams from 99-05 also used the 4t40e - 4t45e.