After you file

Yes, you can amend those past years to file jointly with her new social security number and yes, make the election 6013(g). You will likely get a refund. Don’t worry about an audit if you have done everything correctly.