From f64a7d720f3a9bff58342a582fd0365a2e17c5c3 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Mon, 13 Nov 2023 15:00:47 +0100 Subject: [PATCH] fix: `assignedUser` can be an empty object --- .../capture-core/converters/serverToClient.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core_modules/capture-core/converters/serverToClient.js b/src/core_modules/capture-core/converters/serverToClient.js index 0115b1d7d6..288948461e 100644 --- a/src/core_modules/capture-core/converters/serverToClient.js +++ b/src/core_modules/capture-core/converters/serverToClient.js @@ -11,18 +11,14 @@ function convertTime(d2Value: string) { return parseData.momentTime; } -const convertAssignedUserToClient = (assignedUser?: ApiAssignedUser) => { - if (!assignedUser) { - return null; - } - return { +const convertAssignedUserToClient = (assignedUser?: ApiAssignedUser) => + ((assignedUser && assignedUser.uid) ? { id: assignedUser.uid, name: assignedUser.displayName, username: assignedUser.username, firstName: assignedUser.firstName, surname: assignedUser.surname, - }; -}; + } : null); const optionSetConvertersForType = { [dataElementTypes.NUMBER]: parseNumber,