The closest thing I found to what is happening was MC-224875 marked as resolved but if this gets tagged as a duplicate It Is Not Resolved!
I had this same problem both yesterday May 9, 2022 and again today, May 10, 2022 while trying to add players to our whitelisted Minecraft Java server running 1.18.1 vanilla, with the same command I have used for the past 3 years running our server which is /whitelist add <playername> It has always worked whether or not the player is online or not, but instead it returned the same error both times "player does not exist" I checked out both player names with the website https://namemc.com, both looked legit and gave uuid of player etc. My next experiment was to try and whitelist someone who I knew was on our whitelist but added when we used Mojang accounts, but is now migrated to a Microsoft account, (my husband's account) so I am sure it is legit. I expected the familiar "the player is already whitelisted", but NO! I go "Player Does Not Exist" I had my husband try and log in using the standard Minecraft launcher, he got a message that he had to migrate. He migrated several months ago. We went to his Microsoft account and Xbox account pages, everything was perfect, he Was and is migrated. Our hosting service suggested we re-enter every person on the whitelist manually in the file, but said it was only a guess, but not practical as we have hundreds of people on that list.
Cannot reproduce.
Also please note that 1.18.1 is outdated and no longer supported. Please update to the latest stable version and see if this works.