From efbbda3de71002b7a1f30e1e0f2bb3ec7c7a6b90 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Wed, 17 Apr 2024 05:27:35 +0530 Subject: [PATCH 1/5] Allow the requestee in 1:1 transactions to hold requests --- src/components/MoneyRequestHeader.tsx | 2 +- src/pages/iou/HoldReasonPage.tsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index f451f5f15581..1ce9fa31385e 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -97,7 +97,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, IOU.unholdRequest(iouTransactionID, report?.reportID); } else { const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams()); - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? '', iouTransactionID, report?.reportID, activeRoute)); + Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, iouTransactionID, report?.reportID, activeRoute)); } }; diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 2a5cba810759..52387fd3a377 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -46,6 +46,11 @@ function HoldReasonPage({route}: HoldReasonPageProps) { const {transactionID, reportID, backTo} = route.params; const report = ReportUtils.getReport(reportID); + + // We check if the report is part of a policy, if not then it's a personal request (1:1 request) + // We need to allow both users in the 1:1 request to put the request on hold + const isWorkspaceRequest = ReportUtils.isGroupPolicy(report); + console.log('isWorkspaceRequest', isWorkspaceRequest); const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? ''); const navigateBack = () => { @@ -53,7 +58,10 @@ function HoldReasonPage({route}: HoldReasonPageProps) { }; const onSubmit = (values: FormOnyxValues) => { - if (!ReportUtils.canEditMoneyRequest(parentReportAction)) { + // We have extra !!isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false + // as we do not allow requestee to edit fields like description and amount, + // but we still want the requestee to be able to put the request on hold + if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { return; } @@ -68,7 +76,11 @@ function HoldReasonPage({route}: HoldReasonPageProps) { if (!values.comment) { errors.comment = 'common.error.fieldRequired'; } - if (!ReportUtils.canEditMoneyRequest(parentReportAction)) { + + // We have extra !!isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false + // as we do not allow requestee to edit fields like description and amount, + // but we still want the requestee to be able to put the request on hold + if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { const formErrors = {}; ErrorUtils.addErrorMessage(formErrors, 'reportModified', 'common.error.requestModified'); FormActions.setErrors(ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM, formErrors); From 9711d32ac5e541d96feb99bb1b66d9c550deb36c Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Wed, 17 Apr 2024 05:35:47 +0530 Subject: [PATCH 2/5] Remove console log --- src/pages/iou/HoldReasonPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 52387fd3a377..2740fcb0a79a 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -50,7 +50,6 @@ function HoldReasonPage({route}: HoldReasonPageProps) { // We check if the report is part of a policy, if not then it's a personal request (1:1 request) // We need to allow both users in the 1:1 request to put the request on hold const isWorkspaceRequest = ReportUtils.isGroupPolicy(report); - console.log('isWorkspaceRequest', isWorkspaceRequest); const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? ''); const navigateBack = () => { @@ -58,7 +57,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) { }; const onSubmit = (values: FormOnyxValues) => { - // We have extra !!isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false + // We have extra isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false // as we do not allow requestee to edit fields like description and amount, // but we still want the requestee to be able to put the request on hold if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { @@ -76,8 +75,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) { if (!values.comment) { errors.comment = 'common.error.fieldRequired'; } - - // We have extra !!isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false + // We have extra isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false // as we do not allow requestee to edit fields like description and amount, // but we still want the requestee to be able to put the request on hold if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { From 56c484e5432ebdb77dd13da8ce928f85be3929dc Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Wed, 17 Apr 2024 05:48:20 +0530 Subject: [PATCH 3/5] add isWorkspaceRequest as dependency --- src/pages/iou/HoldReasonPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 2740fcb0a79a..6e31f6202383 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -86,7 +86,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) { return errors; }, - [parentReportAction], + [parentReportAction, isWorkspaceRequest], ); useEffect(() => { From 272b35d134e52133f2c129874f370984e3fe83d0 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Fri, 19 Apr 2024 14:35:31 +0530 Subject: [PATCH 4/5] Update comments based on suggestions --- src/pages/iou/HoldReasonPage.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 6e31f6202383..ad488f6cfad2 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -47,8 +47,8 @@ function HoldReasonPage({route}: HoldReasonPageProps) { const report = ReportUtils.getReport(reportID); - // We check if the report is part of a policy, if not then it's a personal request (1:1 request) - // We need to allow both users in the 1:1 request to put the request on hold + // We first check if the report is part of a policy - if not, then it's a personal request (1:1 request) + // For personal requests, we need to allow both users to put the request on hold const isWorkspaceRequest = ReportUtils.isGroupPolicy(report); const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? ''); @@ -57,9 +57,9 @@ function HoldReasonPage({route}: HoldReasonPageProps) { }; const onSubmit = (values: FormOnyxValues) => { - // We have extra isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false - // as we do not allow requestee to edit fields like description and amount, - // but we still want the requestee to be able to put the request on hold + // We have extra isWorkspaceRequest condition since, for 1:1 requests, canEditMoneyRequest will rightly return false + // as we do not allow requestee to edit fields like description and amount. + // But, we still want the requestee to be able to put the request on hold if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { return; } @@ -75,9 +75,9 @@ function HoldReasonPage({route}: HoldReasonPageProps) { if (!values.comment) { errors.comment = 'common.error.fieldRequired'; } - // We have extra isWorkspaceRequest condition as in case of 1:1 request, canEditMoneyRequest will rightly return false - // as we do not allow requestee to edit fields like description and amount, - // but we still want the requestee to be able to put the request on hold + // We have extra isWorkspaceRequest condition since, for 1:1 requests, canEditMoneyRequest will rightly return false + // as we do not allow requestee to edit fields like description and amount. + // But, we still want the requestee to be able to put the request on hold if (!ReportUtils.canEditMoneyRequest(parentReportAction) && isWorkspaceRequest) { const formErrors = {}; ErrorUtils.addErrorMessage(formErrors, 'reportModified', 'common.error.requestModified'); From 980248746b0babba61e298f4a883402cf2e250af Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sat, 20 Apr 2024 02:34:07 +0530 Subject: [PATCH 5/5] fix merge conflict --- src/components/MoneyRequestHeader.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 8b88509fc5f0..b8f2c7cd1dbd 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -96,16 +96,8 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, if (isOnHold) { IOU.unholdRequest(iouTransactionID, report?.reportID); } else { - if (!policy?.type) { - return; - } - const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams()); -<<<<<<< HEAD Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, iouTransactionID, report?.reportID, activeRoute)); -======= - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy.type, iouTransactionID, report?.reportID, activeRoute)); ->>>>>>> main } };