Broadly, you're ok for some years of non residence.
The tax law in the UK says that there's no gains tax on any gain made when selling a property for the period that it was your main residence.
There are rules that apply when a house has been but is not your main residence - https://www.gov.uk/tax-sell-home/absence-from-home
You say that letting the property might 'disqualify' you from claiming the property was your main residence and that's true. HMRC expect upon a sale is that you pro-rata any gain you make into the period relating to your prime residence occupation (X) and that period where you were not (Y), so tax is levied on (Y / (X+Y) ) times the gain. But the tax law gives enhancements for X, and by implication reduce Y.
These enhancements include an extra three years anyway, like a bonus. And 1.5 years at the end of the whole period of ownership. What these usually mean is that you can let away for 4.5 years without being fussed about gains tax (and permit me to assume you are UK resident and domiciled so there's no other country that would try to tax you as well).
What you did not ask about was lettings relief, which typically gives you another 40k of tax free gains. The regulation sets the 40k as a maximum, and the actual computation doubles the period of exemption due to private residence relief with an effective top limit of 40k.
Would it make any difference to move back into the property before selling? Well, yes because it would increase the proportion of the gain which was exempt due to main residence relief. That's usually the only effect. But be careful to understand that I'm assuming there's no question the house was your prime residence. I mean, there had to have been sufficient documentation to evidence that it was in fact your residence. Would it make any difference to the tax you will pay? Possibly not. You'd have to do the computation.
Finally, you have probably read about all those UK politicians buying houses in London and then electing them to be their prime residence and then selling them tax free, while at the same time holding on to their properties back in their constituencies. They are making use of the ability to nominate a house as your prime residence but this is only permitted where it could be either, and within two years of the condition arising where it could be either. My guess is this uncertainty does not currently apply to you.
Tax law changes every year, so check the HMRC site. Under the self assessment rules, HMRC will assume you know what the tax law says.