Gonna play devil's advocate here... if the Tesla rep has made you this offer, my first instinct is that they know they screwed the pooch big time on this, and could really be on the hook for a whole lot more than just replacing your car at the same price you paid. After all the stories I've read here about how inflexible Tesla is when it comes to orders and money --- takes an act of God to get your $250 back if you cancel and in some cases they force the contract --- I'm more than a little surprised they made the offer they did. So, my naturally suspicious nature, plus my 70 year old instincts dealing with people who screwed up trying to make things right, says a Saul Goodman-type lawyer would have you in a new Plaid with a lifetime of free charging, plus he'd get a car for himself, nothing out of pocket for you.
Having said that... I'd take the deal. Why? Because it gets you where you want and need to be, albeit with having to go through a few buying and selling gymnastics. I get the "teach them a lesson" part of why you go after bad behavior, but I'm not thinking you'd make much of an impact in this case, mostly because I'd guess this is more of a one-off screw up than a regular Tesla selling strategy. What advantage would they gain in the market by routinely selling previously wrecked cars? This isn't Joe's Used Car Lot we're talking about.
Buy the M3 at that incredibly attractive $40k price. Flip it as brand new, take the dough and buy your Model Y. Tesla ducks a lawsuit, you --- more importantly --- duck however long it takes to settle that suit, plus you get what you should have gotten in the first place. Life's too short. Trust me on that one.