In the original introduction of the lobby, there was a GUI message sent for every player status change (such as busy -> online).
Each time such a message was received, a JS cache of the lobby status was incrementally updated, and the lobby playerlist was rebuilt on that.
This turned out to be a big problem (#3386), because if one plays a game for 1 or 2 hours, there would be several hundreds of these messages.
It was also bugged because first the playerlist was updated and then the incremental patches applied to the too recent playerlist (not the playerlist at the time the message was sent).
This was changed to updating the entire list upon receiving such a message.
So returning from the match then meant having to wait for the playerlist to rebuilt several hundred times, which caused serious (10s+) freezes.
Then there was rP16997 that added the erasure function, so that the list was rebuilt only once. (2015)
But better than deleting the message when its not needed is not creating the message to begin with, and only store a single dumb boolean to indicate whether the playerlist needs rebuild or not.
This patch implements it, and it could have been like that in 2015 already.
In rP20040 the fix rP16997 was updated to have one helper function removed, but it didn't go all the way to remove as much as possible and instead added the lobby.js return values.
In rP20070 (2017) the lobby dialog was added, and "historic" GUI messages were added so that one can retrieve chat messages when reopening the lobby page.
This meant that the code complexity of treating these messages was increased.
To solve #4877 / D2264, there will even be more code complexity needed, so better reduce it beforehand, and improve performance also.