Jakub having a male child for starters, and his mother dies earlier (or, since Theresa Kunegunda is married to Joseph Clemens here, he is viewed as less kingly material).
Or well, screw Jakub. Let him die of hunting accident before the marriage with sister of the Empress is consummated, and Jan III, still wanting an alliance, marries
https://en.wikipedia.org/wiki/Aleksander_Benedykt_Sobieski to Hedwig Elisabeth. Aleksander was smarter than Jakub, and was not hated within his own family. If Austrian support goes to him, he may get the throne.