From 7ed0b3c3db3a0d389626365707354983f48645ed Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Thu, 11 Jan 2024 11:14:48 -0500 Subject: [PATCH 1/7] Add EmptyReceiptState to Money Confirmation Page --- .../MoneyRequestConfirmationList.js | 21 ++++++++++++++++++- ...oraryForRefactorRequestConfirmationList.js | 21 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 13dce9337673..1a1bd60daa93 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -36,6 +36,7 @@ import Image from './Image'; import MenuItemWithTopDescription from './MenuItemWithTopDescription'; import optionPropTypes from './optionPropTypes'; import OptionsSelector from './OptionsSelector'; +import ReceiptEmptyState from './ReceiptEmptyState'; import SettlementButton from './SettlementButton'; import ShowMoreButton from './ShowMoreButton'; import Switch from './Switch'; @@ -222,6 +223,8 @@ function MoneyRequestConfirmationList(props) { const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND; + const isFromPaidPolicy = props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE; + const isSplitWithScan = isSplitBill && props.isScanRequest; const {unit, rate, currency} = props.mileageRate; @@ -604,7 +607,7 @@ function MoneyRequestConfirmationList(props) { )} - {(receiptImage || receiptThumbnail) && ( + {receiptImage || receiptThumbnail ? ( + ) : ( + isFromPaidPolicy && ( + + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( + CONST.IOU.ACTION.EDIT, + CONST.IOU.TYPE.REQUEST, + transaction.transactionID, + props.reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ) + } + /> + ) )} {props.shouldShowSmartScanFields && ( )} - {(receiptImage || receiptThumbnail) && ( + {receiptImage || receiptThumbnail ? ( + ) : ( + isFromPaidPolicy && ( + + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( + CONST.IOU.ACTION.EDIT, + CONST.IOU.TYPE.REQUEST, + transaction.transactionID, + reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ) + } + /> + ) )} {shouldShowSmartScanFields && ( Date: Fri, 12 Jan 2024 15:17:04 -0500 Subject: [PATCH 2/7] Fix policy check in MoneyRequestConfirmationList and MoneyTemporaryForRefactorRequestConfirmationList --- src/components/MoneyRequestConfirmationList.js | 5 +++-- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 1a1bd60daa93..bade16f393a3 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -223,7 +223,8 @@ function MoneyRequestConfirmationList(props) { const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND; - const isFromPaidPolicy = props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE; + // A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect") + const isFromPaidPolicy = props.policy && (props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE); const isSplitWithScan = isSplitBill && props.isScanRequest; @@ -622,7 +623,7 @@ function MoneyRequestConfirmationList(props) { onPress={() => Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( - CONST.IOU.ACTION.EDIT, + CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.REQUEST, transaction.transactionID, props.reportID, diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index aba5605a3f6b..140afd8a3d85 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -253,7 +253,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = iouType === CONST.IOU.TYPE.SEND; - const isFromPaidPolicy = policy.type === CONST.POLICY.TYPE.TEAM || policy.type === CONST.POLICY.TYPE.CORPORATE; + // A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect") + const isFromPaidPolicy = policy && (policy.type === CONST.POLICY.TYPE.TEAM || policy.type === CONST.POLICY.TYPE.CORPORATE); const {unit, rate, currency} = mileageRate; const distance = lodashGet(transaction, 'routes.route0.distance', 0); @@ -656,7 +657,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ onPress={() => Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( - CONST.IOU.ACTION.EDIT, + CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.REQUEST, transaction.transactionID, reportID, From b6021f6c5c45d98a732ead1803010e7586567165 Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Mon, 22 Jan 2024 10:52:24 -0500 Subject: [PATCH 3/7] Update src/components/MoneyRequestConfirmationList.js Co-authored-by: Aimane Chnaif <96077027+aimane-chnaif@users.noreply.github.com> --- src/components/MoneyRequestConfirmationList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 97bd32dcaa1a..3dc257ebdf50 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -624,7 +624,7 @@ function MoneyRequestConfirmationList(props) { Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.CREATE, - CONST.IOU.TYPE.REQUEST, + iouType transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams(), From fe866c4c61b7bb4113b71114d4f3a2dcb5393e9f Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Mon, 22 Jan 2024 10:52:31 -0500 Subject: [PATCH 4/7] Update src/components/MoneyTemporaryForRefactorRequestConfirmationList.js Co-authored-by: Aimane Chnaif <96077027+aimane-chnaif@users.noreply.github.com> --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 4b3d4efc8a8a..021021d0918f 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -658,7 +658,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.CREATE, - CONST.IOU.TYPE.REQUEST, + iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams(), From 1354c6775aec583a48052451cc42e037a5dd5945 Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Mon, 22 Jan 2024 10:54:04 -0500 Subject: [PATCH 5/7] Update src/components/MoneyTemporaryForRefactorRequestConfirmationList.js Co-authored-by: Aimane Chnaif <96077027+aimane-chnaif@users.noreply.github.com> --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 021021d0918f..cab980a34850 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -652,7 +652,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} /> ) : ( - isFromPaidPolicy && ( + isFromPaidPolicy && + !isDistanceRequest && + iouType === CONST.IOU.TYPE.REQUEST && ( Navigation.navigate( From 06d1c08693d6b69393a4f795b91c82640e1192ee Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Mon, 22 Jan 2024 10:54:15 -0500 Subject: [PATCH 6/7] Update src/components/MoneyRequestConfirmationList.js Co-authored-by: Aimane Chnaif <96077027+aimane-chnaif@users.noreply.github.com> --- src/components/MoneyRequestConfirmationList.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 3dc257ebdf50..3cc94102ee57 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -618,7 +618,10 @@ function MoneyRequestConfirmationList(props) { isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} /> ) : ( - isFromPaidPolicy && ( +```suggestion + isFromPaidPolicy && + !isDistanceRequest && + iouType === CONST.IOU.TYPE.REQUEST && ( Navigation.navigate( From a2ff790f5adfb4f5c44ffb94b0e4c13e82377f9f Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Mon, 22 Jan 2024 11:14:52 -0500 Subject: [PATCH 7/7] Refactor empty receipt component logic in MoneyRequestConfirmationList and MoneyTemporaryForRefactorRequestConfirmationList --- src/components/MoneyRequestConfirmationList.js | 13 +++++-------- ...yTemporaryForRefactorRequestConfirmationList.js | 14 +++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 3cc94102ee57..590154b48bca 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -223,9 +223,6 @@ function MoneyRequestConfirmationList(props) { const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND; - // A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect") - const isFromPaidPolicy = props.policy && (props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE); - const isSplitWithScan = isSplitBill && props.isScanRequest; const {unit, rate, currency} = props.mileageRate; @@ -618,16 +615,16 @@ function MoneyRequestConfirmationList(props) { isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} /> ) : ( -```suggestion - isFromPaidPolicy && - !isDistanceRequest && - iouType === CONST.IOU.TYPE.REQUEST && ( + // The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate") + PolicyUtils.isPaidGroupPolicy(props.policy) && + !props.isDistanceRequest && + props.iouType === CONST.IOU.TYPE.REQUEST && ( Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.CREATE, - iouType + props.iouType, transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams(), diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index cab980a34850..57a2094d6295 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -253,9 +253,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = iouType === CONST.IOU.TYPE.SEND; - // A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect") - const isFromPaidPolicy = policy && (policy.type === CONST.POLICY.TYPE.TEAM || policy.type === CONST.POLICY.TYPE.CORPORATE); - const {unit, rate, currency} = mileageRate; const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; @@ -652,19 +649,14 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} /> ) : ( - isFromPaidPolicy && + // The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate") + PolicyUtils.isPaidGroupPolicy(policy) && !isDistanceRequest && iouType === CONST.IOU.TYPE.REQUEST && ( Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transaction.transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), + ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ) } />