From 190e84a81fa68eae92a6141bd3271a71dc8e89b5 Mon Sep 17 00:00:00 2001 From: Ismael Dosil Date: Tue, 27 Jan 2026 18:27:23 -0300 Subject: [PATCH] fix(all-users): read legacy programId formats in getAllUsers() Add fallback logic to read program data from multiple field formats: - Priority 1: programs array (current format) - Priority 2: programId string (legacy format - 55 users) - Priority 3: program field (legacy name or ID) This fixes program display for users with legacy data structures. Closes CHALK-080 --- src/components/Firebase/Firebase.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/Firebase/Firebase.tsx b/src/components/Firebase/Firebase.tsx index 923c7c5fc..09226e1bd 100644 --- a/src/components/Firebase/Firebase.tsx +++ b/src/components/Firebase/Firebase.tsx @@ -4762,10 +4762,26 @@ class Firebase { const data = doc.data() // Get first program name from user's programs array let programName = '' + // Priority 1: programs array (current format) if (data.programs && Array.isArray(data.programs) && data.programs.length > 0) { const firstProgramId = data.programs[0].id || data.programs[0] programName = programsMap.get(firstProgramId) || '' } + // Priority 2: programId string (legacy format) + else if (data.programId && typeof data.programId === 'string') { + programName = programsMap.get(data.programId) || '' + } + // Priority 3: program field (legacy - could be name or ID) + else if (data.program && typeof data.program === 'string') { + if (programsMap.has(data.program)) { + programName = programsMap.get(data.program) || '' + } else { + const isExistingName = Array.from(programsMap.values()).includes(data.program) + if (isExistingName) { + programName = data.program + } + } + } result.push({ id: doc.id, firstName: data.firstName || '',