I wish I could say that I haven't done this myself, but I TRY to not lie about such things...
There's 3 things I can think of offhand that will cause the 5th-gear situation:
1. The floppy "C" shift fork isn't engaging the mainshaft right when the cases are closed. This one is sometimes accompanied by either a no-4th-gear-either, or it jumps out of 4th. I once even put this fork in upside-down, in the dark garage, and with the engine upside-down, it shifted all 5 gears fine - until I put the engine back in the bike, filled it with oil, and it was run. Had to pull the whole bike apart again to 'fix' it, and I verified my [stupidity] by ruining the oil pan gasket as I pulled it off to look up inside and see that I really did that, grr...
2. The "C" fork might be bent or worn, or the sliding gear on the mainshaft might have the groove worn wider than it should be (same problem, not enough fork "travel"). The F2/3 bikes suffer this the most, followed by the K7/8 bikes. That sliding gear (and maybe the fork) might need to be changed to fix this one, but the damage is pretty evident to the eye, in the groove and on the fork 'tines'.
3. There is (or not) a spacer on the end of the mainshaft, which works in conjunction with the snapring on the other side of the 5th gear (nearer the clutch end). This spacer on the end, by the 5th gear, is either 0 (not there), 0.5mm, 1.0mm, or 1.5mm thick. I think they went all the way to 2.0mm in the old parts lists Honda used to have, way back when. There is (usually) a spacer between the snapring and the 5th gear on the opposite side, or it might be a collection of 3 parts: a thin thrust washer, a ridged oiling washer, and another thicker (or not) thrust washer, in a sandwiched arrangement. Honda never defined how to set this, but I have figured out that it has to do with the non-standard bearing groove on the nearby bearing, the non-standard length of the inner ball race on that same bearing and the one over by the clutch, and manufacturing tolerances on the mainshaft, that stack up to the shoulder on the end of that shaft where it slides into the bearing. All together, there must not be 0.5mm of "slack", or side-to-side motion, of the 5th gear when the mainshaft is assembled and sitting in the case (or at least, that's what I go by now...). If the snapring comes loose from its groove or the thin thrust washers get bunged up, this spacing can change and 5th (or even 4th) gear can become barely engaged.
The 5th gear becomes final-spaced by the bearing on the end of the shaft, when it is set into the case, because of the retaining ring on the bearing. This sets the final "looseness" side-to-side (I hope that all makes sense?).
On snaprings:
The snaprings are supposed to be (but are not always) oriented so the rounded side is toward the moving gear (or thrust washer) next to it. If the flat side is placed against the spinning part instead, the (splashed) oil film will be too thin and the ring can work itself out of the groove. One case: Gammaflat's K6 did this some years ago (on his countershaft). I have seen virgin engines (K4 and later) with the snaprings backward on several occasions: two of these engines suffered "dislodged" snaprings which caused intermittent gear problems, one which the [chopper] rider put up with for 20 years before I found it (it would 'clunk' when the bike was in 3rd and leaned into a left turn). I don't ever remember seeing this assembly error on the pre-K4 bikes, so I surmise the technicians changed along in there, somewhere?
You can try to measure the insertion depth of the mainshaft's sliding gear into the 5th gear, but it's tricky. There is supposed to be 3mm minimum, 6mm max (I've never seen 6mm) of 'penetration', as the old manuals put it...On most of the post-1976 bikes I've measured this, it was barely 3mm. This is where those shim thicknesses on both sides of the 5th gear come into play: if there isn't enough depth, the shim spacer could be increased to move the gear over more, or removed, as the case may be...it is the machining of the width of the upper case's bearing races, plus the non-standard retaining ring groove on those mainshaft bearings, plus the non-standard width of the inner race collar of those grooved bearings, that cause all of this. I suppose this is why Honda's part manuals listed these bearings as "Special High-Speed Bearing", back in their days?