Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Infinite loading in policy expense chat when changing from auditor to employee #35923

Merged
merged 16 commits into from
Mar 18, 2024
Merged
Changes from 8 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
14 changes: 13 additions & 1 deletion src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ function getReportID(route) {
return String(lodashGet(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 {Object} report
* @returns {Boolean}
*/
function isDeletedReport(report) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this still be true when report is real empty?
I suggest this return true when report is null, undefined, {} as well.
And function name can just be isEmpty

Copy link
Contributor Author

@tienifr tienifr Feb 26, 2024

Choose a reason for hiding this comment

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

Will this still be true when report is real empty?

Yes it will still be true with null, undefined and {}.

And function name can just be isEmpty

Updated!

return _.every(report, _.isUndefined);
}

function ReportScreen({
betas,
route,
Expand Down Expand Up @@ -421,7 +433,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)) && _.isEmpty(report))
((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport) || ReportUtils.isPolicyExpenseChat(prevReport)) && isDeletedReport(report))
) {
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Expand Down
Loading