No, it’s a bad answer.
The only way to solve my problem is as follows.
1. Quit the Messages app on your Mac.
2. Open the Finder and press Command-Shift-G.
3. Type in ~/Library/Messages/ and click Go.
4. Locate the chat.db file in that folder.
5. Drag the chat.db file to your desktop or another safe location as a backup.
6. Once the backup is done, delete the original chat.db file from the Messages folder.
7. Restart your Mac.
8. Open the Messages app and check the icon in the dock and launchpad to see if there are still any unread messages.
This process will reset the Messages database, which may solve the issue of the unread messages notification. However, keep in mind that this will also delete your message history. Therefore, it's always a good idea to have a backup of your chat database before attempting this.