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

Add hold option to report detail page for combine report #44880

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Changes from 1 commit
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: 9 additions & 5 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
// 2. MoneyReport case
if (caseID === CASES.MONEY_REPORT) {
if (!reportActions || !transactionThreadReport?.parentReportActionID) {
return null;
return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah why are we returning undefined instead of null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcochavezf because PromotedActions.hold accepts reportAction param with type ReportAction | undefined, return undefined to avoid ts error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, thanks for the clarification!

}
return reportActions.find((action) => action.reportActionID === transactionThreadReport.parentReportActionID);
}
Expand All @@ -183,6 +183,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
return report;
}, [caseID, parentReport, report]);

const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction;

const canModifyTask = Task.canModifyTask(report, session?.accountID ?? -1);
const shouldShowTaskDeleteButton =
isTaskReport &&
Expand Down Expand Up @@ -446,9 +448,11 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? ''
: '';

const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(parentReportAction);
const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(moneyRequestAction);
const shouldShowHoldAction =
caseID !== CASES.MONEY_REPORT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && !ReportUtils.isArchivedRoom(parentReport);
caseID !== CASES.DEFAULT &&
(canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) &&
!ReportUtils.isArchivedRoom(transactionThreadReportID ? report : parentReport);

const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy);

Expand All @@ -460,7 +464,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
}

if (isExpenseReport && shouldShowHoldAction) {
result.push(PromotedActions.hold({isTextHold: canHoldUnholdReportAction.canHoldRequest, reportAction: parentReportAction}));
result.push(PromotedActions.hold({isTextHold: canHoldUnholdReportAction.canHoldRequest, reportAction: moneyRequestAction}));
}

if (report) {
Expand All @@ -470,7 +474,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
result.push(PromotedActions.share(report));

return result;
}, [report, parentReportAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest]);
}, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest]);

const nameSectionExpenseIOU = (
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
Expand Down
Loading