Skip to content
Merged
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
16 changes: 15 additions & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ function getReportID(route: ReportScreenNavigationProps['route']): string {
return String(route.params?.reportID || 0);
}

/**
* Check is the report is deleted.
* We currently use useMemo to memorize every properties of the report
* so we can't check using isEmpty.
*
* @param report
*/
function isEmpty(report: OnyxTypes.Report): boolean {
if (isEmptyObject(report)) {
return true;
}
return !Object.values(report).some((value) => value !== undefined && value !== '');
}

function ReportScreen({
betas = [],
route,
Expand Down Expand Up @@ -382,7 +396,7 @@ function ReportScreen({
!onyxReportID &&
prevReport.statusNum === CONST.REPORT.STATUS_NUM.OPEN &&
(report.statusNum === CONST.REPORT.STATUS_NUM.CLOSED || (!report.statusNum && !prevReport.parentReportID && prevReport.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM))) ||
((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && isEmptyObject(report))
((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport) || ReportUtils.isPolicyExpenseChat(prevReport)) && isEmpty(report))
) {
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Expand Down