/** * Resolve the display name for a task / scheduled-task owner. * * - A real user name (resolved from the users JOIN) is shown as-is. * - No-auth single-user deployments own rows under 'local' (new rows) or NULL * (legacy rows created before owner registration was fixed). Both render as * 'local' so the lone local operator is shown consistently — instead of the * misleading 'system' / 'user' labels the views used to fall back to. * - An owner id with no matching user record (e.g. a deleted account in an auth * deployment) falls back to 'system'. */ export function ownerDisplayName( ownerId: string | null | undefined, ownerName: string | null | undefined, ): string { if (ownerName) return ownerName; if (ownerId == null || ownerId === 'local') return 'local'; return 'system'; }