Which will destroy the Earth first: the Sun or Jupiter?
I found an article by Ian O'Neill posted on May 2, 2008 at universetoday.com with the title Could Jupiter Wreck the Solar System? which says

But here’s the kicker: There is only a 1% chance that these gravitational instabilities of the inner Solar System are likely to cause any kind of chaos before the Sun turns into a Red Giant and swallows Mercury, Venus, Earth and Mars in 7 billion years time.

This is clearly after the time when the Sun is becoming a red giant in 4.5 – 5.5 billion years - this is the number given in an article Will Earth survive when the sun becomes a red giant? by
Matt Williams from 2016.
References
The first post is refering to a scientific article On the Dynamical Stability of the Solar System by Konstantin Batygin and Gregory Laughlin.