From cbcaf52a5d115f6f634fe9461eeacab423e66991 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Sun, 5 Jan 2025 19:44:53 -0800 Subject: [PATCH 1/2] FIX: Three QA guides in mention suggestion list after onboarding with Manage my team's expenses --- .../home/report/ReportActionCompose/SuggestionMention.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index b69a26e5f90e..85e6de2e40f3 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -280,7 +280,7 @@ function SuggestionMention( }); } - const filteredPersonalDetails = Object.values(personalDetailsParam ?? {}).filter((detail) => { + const filteredPersonalDetails = Object.values(personalDetailsParam ?? {}).filter((detail, index, array) => { // If we don't have user's primary login, that member is not known to the current user and hence we do not allow them to be mentioned if (!detail?.login || detail.isOptimisticPersonalDetail) { return false; @@ -302,7 +302,9 @@ function SuggestionMention( return false; } - return true; + // on staging server, in specific cases (see issue) BE returns duplicated personalDetails + // entries with the same `login` which we need to filter out + return array.findIndex((arrayDetail) => arrayDetail?.login === detail?.login) === index; }) as Array; // At this point we are sure that the details are not null, since empty user details have been filtered in the previous step From 0a8c98fcbc012b91c85777f4b8b73a4c447cb458 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 6 Jan 2025 12:46:47 -0800 Subject: [PATCH 2/2] fixed rulesdir/no-default-id-values lint error --- src/libs/ReportUtils.ts | 4 ++-- .../home/report/ReportActionCompose/SuggestionMention.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9c6377474e78..77f01342ec3c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8429,8 +8429,8 @@ function getOutstandingChildRequest(iouReport: OnyxInputOrEntry): Outsta return {}; } -function canReportBeMentionedWithinPolicy(report: OnyxEntry, policyID: string): boolean { - if (report?.policyID !== policyID) { +function canReportBeMentionedWithinPolicy(report: OnyxEntry, policyID: string | undefined): boolean { + if (!policyID || report?.policyID !== policyID) { return false; } diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 85e6de2e40f3..8127d26251ff 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -336,7 +336,7 @@ function SuggestionMention( (searchTerm: string, reportBatch: OnyxCollection): Mention[] => { const filteredRoomMentions: Mention[] = []; Object.values(reportBatch ?? {}).forEach((report) => { - if (!ReportUtils.canReportBeMentionedWithinPolicy(report, policyID ?? '-1')) { + if (!ReportUtils.canReportBeMentionedWithinPolicy(report, policyID)) { return; } if (report?.reportName?.toLowerCase().includes(searchTerm.toLowerCase())) {