Barring some big trade that would probably involve another "high salary player" that is at the end of his deal, we have two options and Ainge/Hayward knew this when he signed this contract (2017) with a player option.
Hayward opts in and takes the $34M (high probability)
Hayward opts out for a "post max" deal elsewhere (low probability)
Thus he opts in and Ainge trades him or we have a really good player on the court for us this year.
As far as the "sign an extension for less money?" (very low probability) because Hayward doesn't "have to" do this.
I guess, if he departs, it might be to the Pacers, but, this NBA trade stuff is such a gamble. You never know.