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 one-expense report loading #50147

Merged
merged 1 commit into from
Oct 9, 2024
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
6 changes: 6 additions & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,14 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
Report.readNewestAction(report?.reportID ?? '');
}, [report]);
const mostRecentReportAction = reportActions.at(0);
const isMostRecentReportIOU = mostRecentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU;
const isSingleIOUReportAction = reportActions.filter((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU).length === 1;
const isSingleExpenseReport = ReportUtils.isExpenseReport(report) && isMostRecentReportIOU && isSingleIOUReportAction;
const isSingleInvoiceReport = ReportUtils.isInvoiceReport(report) && isMostRecentReportIOU && isSingleIOUReportAction;
const shouldShowMostRecentReportAction =
!!mostRecentReportAction &&
Comment on lines 689 to 695
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this case would have already been caught by the !!mostRecentReportAction check, could you elaborate why it wasn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grgia I'm confused a little, could you please clarify how it would have been caught by the !!mostRecentReportAction check? You can also take a look at my proposal, I've tried to describe everything there in details.

Copy link
Contributor

Choose a reason for hiding this comment

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

isMostRecentReportIOU is mostRecentReportAction && is IOU

isSingleExpenseReport and isSingleInvoiceReport both also include the check isMostRecentReportIOU

so I'd think they would have been caught by the !!mostRecentReportAction.

Am I misreading the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, but as you mentioned the isMostRecentReportIOU also includes the check for IOU report action type, and that's the main part of this check.

!isSingleExpenseReport &&
!isSingleInvoiceReport &&
!ReportActionsUtils.isActionOfType(mostRecentReportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) &&
!ReportActionsUtils.isDeletedAction(mostRecentReportAction);

Expand Down
Loading