Skip to content

Commit

Permalink
Merge pull request #35923 from tienifr/fix/34879
Browse files Browse the repository at this point in the history
Fix: Infinite loading in policy expense chat when changing from auditor to employee
  • Loading branch information
roryabraham authored Mar 18, 2024
2 parents 7742bec + 20b108b commit 55495b1
Showing 1 changed file with 15 additions and 1 deletion.
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 @@ -394,7 +408,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

0 comments on commit 55495b1

Please sign in to comment.