I had a similar problem after rebuilding my gearbox a few years ago.
IIRC it worked ok in a static test (with back wheel spun), but on the road it didn't want to shift.
I had the cover off several times, triple checked everything, found nothing wrong.
Then on one last check (you stop looking after you find something don't you), I just happened to notice that the concave surface of the (new) pawl had a shiny mark on it.
It had been rubbing on the ratchet plate as the gearlever returned to its "neutral" position after making a gearshift, thereby dragging the ratchet plate back a little.
When trying to make the next shift, the pawl would miss the next tooth on the ratchet plate because it was out of position.
I solved it by grinding a small amount off the concave face of the pawl. I had bought 2 new pawls when ordering parts for the rebuild. They're cheap and plentiful so I had a backup if it didn't work. But it did work. That was all it took to make it shift perfectly.
You can test for this by just taking the outer cover off (again!) and watch what happens as you move the gearlever.