I think this extension is beneficial to both parties but more Hayward. He is trying to get his cake and eat it too, meaning he wants the $34.2M for next season and he wants to be able to play where he wants to play (which apparently isn't Boston). This extension leaves more time for that scenario to work out. There is probably something more than nothing in the works or they wouldn't bother.
If he opts out, they can still do a sign and trade based on a new contract. For Hayward, that will be at a much lower contract value for next season probably but the Celtics can still get something back (maybe even a better deal with Hayward on a more team friendly contract) and Hayward still gets to play where he wants to play, where ever that is (albeit at a lower salary for next season). In the immortal words of Meatloaf, 2 out of 3 ain't bad (for Hayward that is).