Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Three QA guides in mention suggestion list after onboarding with Manage my team's expenses #54805

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading