Random battles uses Sleep Clause, which prevents multiple Pokemon from being put to sleep by your Pokemon. Because Scyther was already asleep, when G-Max Befuddle happened to pick sleep vs Polteageist, it activated Sleep Clause. You can see it happen in the replay on turn 25.https://replay.pokemonshowdown.com/gen8randombattle-1674255937 to what status is polterggeist immune becose g max befudle didnt work on him