Sometimes the seals garter spring can jump out of its seat when installing the gearbox. Catching on the sprocket retainer groove can cause it.
I've seen a video of some factory mechanics stripping and rebuilding a bike.
They fitted an o-ring to the groove when installing the gearbox.
Then removed the o-ring afterwards, before fitting the sprocket.