From f92292dd3a1090dfa827d5f30a723f715cde18f7 Mon Sep 17 00:00:00 2001 From: dragnoir Date: Fri, 22 Mar 2024 14:09:08 +0100 Subject: [PATCH 1/3] Fix: load report details when refreshing the page on request confirmation step --- src/libs/OptionsListUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 0f83b260c8f2..3fcb588c625c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -741,12 +741,16 @@ function createOption( * Get the option for a given report. */ function getReportOption(participant: Participant): ReportUtils.OptionData { - const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.reportID}`]; + let report = ReportUtils.getReport(participant.reportID); + + if (isEmptyObject(report)) { + report = null; + } const option = createOption( report?.visibleChatMemberAccountIDs ?? [], allPersonalDetails ?? {}, - report ?? null, + report, {}, { showChatPreviewLine: false, From 34971cbd85cfaafdf4419f45f0b51c13cef588b4 Mon Sep 17 00:00:00 2001 From: dragnoir Date: Fri, 22 Mar 2024 16:21:50 +0100 Subject: [PATCH 2/3] Fix: enhance code --- src/libs/OptionsListUtils.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 3fcb588c625c..b31b9fc280d6 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -741,16 +741,12 @@ function createOption( * Get the option for a given report. */ function getReportOption(participant: Participant): ReportUtils.OptionData { - let report = ReportUtils.getReport(participant.reportID); - - if (isEmptyObject(report)) { - report = null; - } + const report = ReportUtils.getReport(participant.reportID); const option = createOption( report?.visibleChatMemberAccountIDs ?? [], allPersonalDetails ?? {}, - report, + !isEmptyObject(report) ? report : null, {}, { showChatPreviewLine: false, From a38370f966fddfd8389e76c019ddb46d112a85bf Mon Sep 17 00:00:00 2001 From: dragnoir Date: Fri, 22 Mar 2024 16:30:16 +0100 Subject: [PATCH 3/3] Fix: remove all Reports --- src/libs/OptionsListUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index b31b9fc280d6..69d26f174a48 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -249,11 +249,9 @@ Onyx.connect({ }); const policyExpenseReports: OnyxCollection = {}; -const allReports: OnyxCollection = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (report, key) => { - allReports[key] = report; if (!ReportUtils.isPolicyExpenseChat(report)) { return; }