Skip to content

Commit 78ce81d

Browse files
committed
User owes /bin/zsh.00 appears in search after deleting expense
1 parent 014edee commit 78ce81d

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/components/OptionListContextProvider.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
5050
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true});
5151
const prevReportAttributesLocale = usePrevious(reportAttributes?.locale);
5252
const [reports, {sourceValue: changedReports}] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
53+
const prevReports = usePrevious(reports);
5354
const [, {sourceValue: changedReportActions}] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true});
5455
const personalDetails = usePersonalDetails();
5556
const prevPersonalDetails = usePrevious(personalDetails);
@@ -87,11 +88,14 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
8788
}, [prevReportAttributesLocale, loadOptions, reportAttributes?.locale]);
8889

8990
const changedReportsEntries = useMemo(() => {
90-
const result: OnyxCollection<Report> = {};
91+
const result: OnyxCollection<Report | null> = {};
9192

9293
Object.keys(changedReports ?? {}).forEach((key) => {
93-
const report = reports?.[key];
94-
if (report) {
94+
let report: Report | null = reports?.[key] ?? null;
95+
if (reports?.[key] === undefined && prevReports?.[key]) {
96+
report = null;
97+
}
98+
if (report !== undefined) {
9599
result[key] = report;
96100
}
97101
});

src/libs/OptionsListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ function isReportSelected(reportOption: OptionData, selectedOptions: Array<Parti
12001200
}
12011201

12021202
function processReport(
1203-
report: OnyxEntry<Report>,
1203+
report: OnyxEntry<Report> | null,
12041204
personalDetails: OnyxEntry<PersonalDetailsList>,
12051205
): {
12061206
reportMapEntry?: [number, Report]; // The entry to add to reportMapForAccountIDs if applicable

0 commit comments

Comments
 (0)