Skip to content
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: 1 addition & 2 deletions src/components/OptionListContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
const personalDetails = usePersonalDetails();
const prevPersonalDetails = usePrevious(personalDetails);
const hasInitialData = useMemo(() => Object.keys(personalDetails ?? {}).length > 0, [personalDetails]);
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true});

const loadOptions = useCallback(() => {
const optionLists = createOptionList(personalDetails, reports, reportAttributes?.reports);
Expand Down Expand Up @@ -165,7 +164,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
reports: Array.from(updatedReportsMap.values()),
};
});
}, [changedReportActions, personalDetails, reportAttributes?.reports, transactions]);
}, [changedReportActions, personalDetails, reportAttributes?.reports]);

/**
* This effect is used to update the options list when personal details change.
Expand Down
13 changes: 3 additions & 10 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ import type {
} from '@src/types/onyx';
import type {Attendee, Participant} from '@src/types/onyx/IOU';
import type {OriginalMessageMovedTransaction} from '@src/types/onyx/OriginalMessage';
import type {SearchTransaction} from '@src/types/onyx/SearchResults';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {
FilterUserToInviteConfig,
Expand Down Expand Up @@ -757,7 +756,6 @@ function createOption(
report: OnyxInputOrEntry<Report>,
config?: PreviewConfig,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
transactions?: SearchTransaction[],
): SearchOptionData {
const {showChatPreviewLine = false, forcePolicyNamePreview = false, showPersonalDetails = false, selected, isSelected, isDisabled} = config ?? {};

Expand Down Expand Up @@ -840,9 +838,7 @@ function createOption(
// If displaying chat preview line is needed, let's overwrite the default alternate text
result.alternateText = showPersonalDetails && personalDetail?.login ? personalDetail.login : getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview});

reportName = showPersonalDetails
? getDisplayNameForParticipant({accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '')
: getReportName(report, undefined, undefined, undefined, undefined, undefined, transactions);
reportName = showPersonalDetails ? getDisplayNameForParticipant({accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '') : getReportName(report);
} else {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
reportName = getDisplayNameForParticipant({accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '');
Expand Down Expand Up @@ -1074,7 +1070,6 @@ function processReport(
report: OnyxEntry<Report> | null,
personalDetails: OnyxEntry<PersonalDetailsList>,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
transactions?: SearchTransaction[],
): {
reportMapEntry?: [number, Report]; // The entry to add to reportMapForAccountIDs if applicable
reportOption: SearchOption<Report> | null; // The report option to add to allReportOptions if applicable
Expand All @@ -1098,7 +1093,7 @@ function processReport(
reportMapEntry,
reportOption: {
item: report,
...createOption(accountIDs, personalDetails, report, undefined, reportAttributesDerived, transactions),
...createOption(accountIDs, personalDetails, report, undefined, reportAttributesDerived),
},
};
}
Expand Down Expand Up @@ -2558,9 +2553,7 @@ function shallowOptionsListCompare(a: OptionList, b: OptionList): boolean {
return false;
}
for (let i = 0; i < a.reports.length; i++) {
const aReport = a.reports.at(i);
const bReport = b.reports.at(i);
if (aReport?.reportID !== bReport?.reportID || aReport?.text !== bReport?.text) {
if (a.reports.at(i)?.reportID !== b.reports.at(i)?.reportID) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed out on checking the condition for text. We fixed this in #83447

return false;
}
}
Expand Down
Loading