How does the chain derail when you’re not turning the crank?
Even if there is / was a bit of chain sag from a dodgy freehub, I’m struggling to visualise how the chain wrapped round a 50 or 52 gets dislodged.
Does this happen immediately when you stop pedalling or after a while?
The fact it stopped after the freehub replacement for a while suggests the mech spring can’t be entirely to blame.