I had a similar mystery shifting issue on my bike last year. I still remember when it started. For a long time I was sure it was the derailleur hanger but multiple attempts to align it never quite corrected it. I even found a broken piece of metal in my right 7900 shifter which Shimano warrantied but that still didn't fix the issue. I replaced cables and housing, I tried adding more Shimano SP-41 grease, and even repeatedly inspected the BB cable guide. The final fix was that my damned rear loop was too short.