in gmail on web with the preview pane enabled for a sorted mailbox:
archiving the first (top) message causes gmail to select the message below the archived message
archiving any non-top messages that aren’t the ultimate (bottom) message causes gmail to select the message above the archived message
archiving the ultimate (bottom) message causes gmail to select the message above the message above the archived message.
🤷🏻♂️