We shouldn't electrify any routes where rail has no place in 'net zero' carbon future.
We know that battery technology and 'other', where other is likely to include hydrogen and very light rail (like the Parry People Mover) can fill in small areas where overhead wires won't be able to go, but this is limited. It's not a catch-all solution.
A good example of this is Girvan to Stranraer. It's a long route with legacy signalling, no intermediate population and low frequency. It has lost relevance, permanently, because it fails to connect with Ferry services, it's one station is very poorly sited, and more importantly it's impossible, now, to offer a direct service to a large city nearby in reasonable time.
Ayr - Girvan offers fast, direct commuting opportunities to Glasgow, if electrified, and an opportunity to exploit at least one new station site. A ScotRail bus service could connect Girvan to Cairnryan and Stranraer better than the train ever could - and at massively lower carbon cost.
This sort of thing is, of course, politically explosive. But it's also the truth: we can't run empty diesel trains through open countryside forever, nor could we possibly electrify Girvan to Stranraer.