2035 (verses 2040 for anything in the DfT's remit).
ScotRail's service delivery director gave an interview with Richard Clinnick last December that appeared in February's edition of Rail Express. If we trust it as being a vaguely credible indication of general intent, than ScotRail's broad-strokes fleet strategy for the next 12 years is to keep both the 170s and HSTs into the 2030s, with the 170s "probably" being the last pure-diesel fleet to go.
The first replacement order that SR is expecting to make is that for the Strathclyde suburban network - a mix of pure-electrics (to replace 318s and 320s, and maybe 334s) and battery-electric units to replace 156s on Barrhead and East Kilbride. Depending on exact timing, that BEMU order might also cover some of the other electrifications, which would allow 158s to take over the West Highland Line and most other services that currently use 156s.
Perhaps unsurprisingly little is said about the HSTs long-term future, other than that they're currently putting the power cars through G-exams at Haymarket (involving a "major rebuild and component replacement"), and that a steering group between SR, Angel Trains, ASLEF, and the RMT has been convened to work through the post-Carmont safety concerns (talks are reported as being "constructive"). There is also an investigation of some sorts underway as to making more room at Inverness for 2+5 sets, which can currently only use two platforms there.
(probably worth nothing at this point that this is the traction and rolling-stock subforum, so anything further on this topic might be better in a new speculative thread.)