I did a bit of digging and uncovered a fairly unobtrusive workaround for this. YMMV, but it worked for me. Tested on macOS 11.4.
By restarting a few system agents, the bug appears to go into remission. This leads me to believe that the root cause is some sort of timing issue or race condition that happens during boot.
Until a proper fix exists, I welcome anyone to try this script (also at luckman212/imessage-number-fix)
#!/usr/bin/env bash
declare -a xpcArr=(
gui/$UID/com.apple.AddressBook.abd
gui/$UID/com.apple.AddressBook.AssistantService
gui/$UID/com.apple.AddressBook.ContactsAccountsService
gui/$UID/com.apple.AddressBook.SourceSync
gui/$UID/com.apple.assistant_service
gui/$UID/com.apple.assistantd
gui/$UID/com.apple.CallHistorySyncHelper
gui/$UID/com.apple.ContactsAgent
gui/$UID/com.apple.iCloudNotificationAgent
gui/$UID/com.apple.imagent
gui/$UID/com.apple.imautomatichistorydeletionagent
gui/$UID/com.apple.notificationcenterui.agent
gui/$UID/com.apple.telephonyutilities.callservicesd
gui/$UID/com.apple.usernoted
gui/$UID/com.apple.UserNotificationCenterAgent
user/$UID/com.apple.imdpersistence.IMDPersistenceAgent
)
for d in "${xpcArr[@]}"; do
echo -n "restarting $d"
read -r PID < <(launchctl kickstart -kp "$d")
if [ -n "$PID" ]; then
echo " ✔ [$PID]"
else
echo " ✘"
fi
done
chat.db
SQLite database?