Skip to content

Commit

Permalink
Merge pull request #54805 from ikevin127/ikevin127-removeSuggestionMe…
Browse files Browse the repository at this point in the history
…ntionDuplicate

FIX: Three QA guides in mention suggestion list after onboarding with Manage my team's expenses
  • Loading branch information
MarioExpensify authored Jan 7, 2025
2 parents eafa649 + 0a8c98f commit adb8ddc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8429,8 +8429,8 @@ function getOutstandingChildRequest(iouReport: OnyxInputOrEntry<Report>): Outsta
return {};
}

function canReportBeMentionedWithinPolicy(report: OnyxEntry<Report>, policyID: string): boolean {
if (report?.policyID !== policyID) {
function canReportBeMentionedWithinPolicy(report: OnyxEntry<Report>, policyID: string | undefined): boolean {
if (!policyID || report?.policyID !== policyID) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<PersonalDetails & {weight: number}>;

// At this point we are sure that the details are not null, since empty user details have been filtered in the previous step
Expand Down Expand Up @@ -334,7 +336,7 @@ function SuggestionMention(
(searchTerm: string, reportBatch: OnyxCollection<Report>): 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())) {
Expand Down

0 comments on commit adb8ddc

Please sign in to comment.