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: Two QA guide entries in the member list after onboarding with Manage my team's expenses #54147

Merged
merged 4 commits into from
Dec 19, 2024
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
3 changes: 3 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
* Get the participant option for a report.
*/
function getParticipantsOption(participant: ReportUtils.OptionData | Participant, personalDetails: OnyxEntry<PersonalDetailsList>): Participant {
const detail = getPersonalDetailsForAccountIDs([participant.accountID ?? -1], personalDetails)[participant.accountID ?? -1];

Check failure on line 365 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Check failure on line 365 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const login = detail?.login || participant.login || '';
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -371,7 +371,7 @@
return {
keyForList: String(detail?.accountID),
login,
accountID: detail?.accountID ?? -1,

Check failure on line 374 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

text: displayName,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
firstName: (detail?.firstName || ('firstName' in participant ? participant.firstName : '')) ?? '',
Expand Down Expand Up @@ -501,7 +501,7 @@
* Get the last message text from the report directly or from other sources for special cases.
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const reportID = report?.reportID ?? '-1';

Check failure on line 504 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const lastReportAction = lastVisibleReportActions[reportID] ?? null;

// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
Expand Down Expand Up @@ -535,7 +535,7 @@
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForMoneyRequestMessage);
} else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) {
const iouReport = ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(

Check failure on line 538 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key, ReportUtils.canUserPerformWriteAction(report)) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
Expand All @@ -557,9 +557,9 @@
lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(lastReportAction, report, true);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportActionUtils.isPendingRemove(lastReportAction) && ReportActionUtils.isThreadParentMessage(lastReportAction, report?.reportID ?? '-1')) {

Check failure on line 560 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

lastMessageTextFromReport = Localize.translateLocal('parentReportAction.hiddenMessage');
} else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, translationKey: report?.lastMessageTranslationKey, type: ''})) {

Check failure on line 562 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
lastMessageTextFromReport = `[${Localize.translateLocal((report?.lastMessageTranslationKey || 'common.attachment') as TranslationPaths)}]`;
} else if (ReportActionUtils.isModifiedExpenseAction(lastReportAction)) {
Expand Down Expand Up @@ -700,7 +700,7 @@
hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || ReportUtils.isGroupChat(report);
subtitle = ReportUtils.getChatRoomSubtitle(report);

const lastActorDetails = personalDetailMap[report.lastActorAccountID ?? -1] ?? null;

Check failure on line 703 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants);
const lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails);
let lastMessageText = lastMessageTextFromReport;
Expand Down Expand Up @@ -915,7 +915,7 @@

const allPersonalDetailsOptions = Object.values(personalDetails ?? {}).map((personalDetail) => ({
item: personalDetail,
...createOption([personalDetail?.accountID ?? -1], personalDetails, reportMapForAccountIDs[personalDetail?.accountID ?? -1], {}, {showPersonalDetails: true}),

Check failure on line 918 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Check failure on line 918 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

}));

return {
Expand Down Expand Up @@ -1859,6 +1859,9 @@

let {recentReports: filteredReports, personalDetails: filteredPersonalDetails} = filterResult;

// on staging server, in specific cases (see issue) BE returns duplicated personalDetails entries
filteredPersonalDetails = filteredPersonalDetails.filter((detail, index, array) => array.findIndex((i) => i.login === detail.login) === index);

if (typeof config?.maxRecentReportsToShow === 'number') {
filteredReports = orderReportOptionsWithSearch(filteredReports, searchInputValue, config);
filteredReports = filteredReports.slice(0, config.maxRecentReportsToShow);
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,21 @@ describe('OptionsListUtils', () => {
expect(filteredResults.recentReports.at(0)?.text).toBe('The Flash');
});
});

it('should filter out duplicated entries by login', () => {
const login = 'brucebanner@expensify.com';

// Duplicate personalDetails entries and reassign to OPTIONS
OPTIONS.personalDetails = OPTIONS.personalDetails.flatMap((obj) => [obj, {...obj}]);

const options = OptionsListUtils.getSearchOptions(OPTIONS, [CONST.BETAS.ALL]);
const filteredOptions = OptionsListUtils.filterAndOrderOptions(options, '');
const matchingEntries = filteredOptions.personalDetails.filter((detail) => detail.login === login);

// There should be 2 unique login entries
expect(filteredOptions.personalDetails.length).toBe(2);
expect(matchingEntries.length).toBe(1);
});
});

describe('canCreateOptimisticPersonalDetailOption', () => {
Expand Down
Loading