In their database every player also have a unique ID number. (That's how databases work)

When you open your friend list, what you see is the names of your friends but in reality what is stored on the server is the unique ID of all your friends. So if some name change, the game server will still find them with that ID