Fall back to displayName when username is null for Discord webhook

Users who sign up via OAuth (Google, GitHub, etc.) without setting a
Clerk username have a null `username` field but always have a `displayName`
(computed from firstName+lastName or email). Previously, `usernameByClerkId`
was filtered to only include users with a non-null username, causing those
owners to appear without any identifier in Discord standings messages
(e.g. "Liverpool def. Galatasaray" instead of "Liverpool def. Galatasaray (Madmike)").

https://claude.ai/code/session_01VAkeDDVZMYS1DweQnUrRnH
This commit is contained in:
Claude 2026-03-18 23:06:00 +00:00
parent 143698cb96
commit 05ba57651f
No known key found for this signature in database

View file

@ -1313,8 +1313,8 @@ export async function recalculateAffectedLeagues(
: []; : [];
const usernameByClerkId = new Map( const usernameByClerkId = new Map(
teamOwnerUsers teamOwnerUsers
.filter((u) => u.username != null) .map((u) => [u.clerkId, u.username ?? u.displayName])
.map((u) => [u.clerkId, u.username!]) .filter((entry): entry is [string, string] => entry[1] != null)
); );
// Build teamId → ownerId map from standings data // Build teamId → ownerId map from standings data