Skip to content

Commit 5c22d74

Browse files
authored
Merge pull request Expensify#64881 from thelullabyy/fix/64565
Expense- "User owes $0.00" appears in search after deleting expense, which opens not here page
2 parents 9e36f05 + 9324205 commit 5c22d74

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);
@@ -88,14 +89,17 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
8889
}, [prevReportAttributesLocale, loadOptions, reportAttributes?.locale]);
8990

9091
const changedReportsEntries = useMemo(() => {
91-
const result: OnyxCollection<OnyxEntry<Report>> = {};
92+
const result: OnyxCollection<OnyxEntry<Report> | null> = {};
9293

9394
Object.keys(changedReports ?? {}).forEach((key) => {
94-
const report = reports?.[key];
95+
let report: Report | null = reports?.[key] ?? null;
9596
result[key] = report;
97+
if (reports?.[key] === undefined && prevReports?.[key]) {
98+
report = null;
99+
}
96100
});
97101
return result;
98-
}, [changedReports, reports]);
102+
}, [changedReports, reports, prevReports]);
99103

100104
/**
101105
* This effect is responsible for updating the options only for changed reports

src/libs/OptionsListUtils.ts

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

12271227
function processReport(
1228-
report: OnyxEntry<Report>,
1228+
report: OnyxEntry<Report> | null,
12291229
personalDetails: OnyxEntry<PersonalDetailsList>,
12301230
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
12311231
transactions?: SearchTransaction[],

0 commit comments

Comments
 (0)