From 32a2cc3de30369be4ba94370abc9ad455a89f851 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 12:25:57 +0300 Subject: [PATCH 1/5] allow split bill --- src/pages/iou/request/step/IOURequestStepTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTag.js b/src/pages/iou/request/step/IOURequestStepTag.js index af1de64f8930..b9df563f6e46 100644 --- a/src/pages/iou/request/step/IOURequestStepTag.js +++ b/src/pages/iou/request/step/IOURequestStepTag.js @@ -81,7 +81,7 @@ function IOURequestStepTag({ const parentReportAction = parentReportActions[report.parentReportActionID]; // eslint-disable-next-line rulesdir/no-negated-variables - const shouldShowNotFoundPage = isEditing && !canEditMoneyRequest(parentReportAction); + const shouldShowNotFoundPage = isEditing && !isSplitBill && !canEditMoneyRequest(parentReportAction); const navigateBack = () => { Navigation.goBack(backTo); From f26d231bd64a44e33fd8a238695c75e01322587e Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 15:25:39 +0300 Subject: [PATCH 2/5] show not found page for read only split bill --- src/ROUTES.ts | 13 ++++++++--- .../MoneyRequestConfirmationList.js | 1 + .../iou/request/step/IOURequestStepTag.js | 22 +++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index cfc287ba2cdc..bca7bb81dbd5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -385,9 +385,16 @@ const ROUTES = { getUrlWithBackToParam(`${action}/${iouType}/scan/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_TAG: { - route: ':action/:iouType/tag/:tagIndex/:transactionID/:reportID', - getRoute: (action: ValueOf, iouType: ValueOf, tagIndex: number, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/tag/${tagIndex}/${transactionID}/${reportID}`, backTo), + route: ':action/:iouType/tag/:tagIndex/:transactionID/:reportID/:reportActionID?', + getRoute: ( + action: ValueOf, + iouType: ValueOf, + tagIndex: number, + transactionID: string, + reportID: string, + backTo = '', + reportActionID?: string, + ) => getUrlWithBackToParam(`${action}/${iouType}/tag/${tagIndex}/${transactionID}/${reportID}${typeof reportActionID === 'string' ? `/${reportActionID}` : ''}`, backTo), }, MONEY_REQUEST_STEP_WAYPOINT: { route: ':action/:iouType/waypoint/:transactionID/:reportID/:pageIndex', diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index fa6de1c2e4f4..94a0c9c35280 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -797,6 +797,7 @@ function MoneyRequestConfirmationList(props) { props.transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams(), + props.reportActionID, ), ); return; diff --git a/src/pages/iou/request/step/IOURequestStepTag.js b/src/pages/iou/request/step/IOURequestStepTag.js index b9df563f6e46..18f8e68d67aa 100644 --- a/src/pages/iou/request/step/IOURequestStepTag.js +++ b/src/pages/iou/request/step/IOURequestStepTag.js @@ -47,6 +47,15 @@ const propTypes = { /** The actions from the parent report */ parentReportActions: PropTypes.shape(reportActionPropTypes), + + /** Session info for the currently logged in user. */ + session: PropTypes.shape({ + /** Currently logged in user accountID */ + accountID: PropTypes.number, + + /** Currently logged in user email */ + email: PropTypes.string, + }).isRequired, }; const defaultProps = { @@ -64,10 +73,11 @@ function IOURequestStepTag({ policyTags, report, route: { - params: {action, tagIndex: rawTagIndex, transactionID, backTo, iouType}, + params: {action, tagIndex: rawTagIndex, transactionID, backTo, iouType, reportActionID}, }, transaction, parentReportActions, + session, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -78,10 +88,11 @@ function IOURequestStepTag({ const tag = TransactionUtils.getTag(transaction, tagIndex); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; - const parentReportAction = parentReportActions[report.parentReportActionID]; + const parentReportAction = parentReportActions[report.parentReportActionID || reportActionID]; + const canEditSplitBill = isSplitBill && parentReportAction && session.accountID === parentReportAction.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction); // eslint-disable-next-line rulesdir/no-negated-variables - const shouldShowNotFoundPage = isEditing && !isSplitBill && !canEditMoneyRequest(parentReportAction); + const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !canEditMoneyRequest(parentReportAction)); const navigateBack = () => { Navigation.goBack(backTo); @@ -151,8 +162,11 @@ export default compose( key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, }, parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID || report.reportID : '0'}`, canEvict: false, }, + session: { + key: ONYXKEYS.SESSION, + }, }), )(IOURequestStepTag); From de5958792d3c2c726751321d8bceb73851216342 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 16:46:13 +0300 Subject: [PATCH 3/5] updated onyx key --- src/pages/iou/request/step/IOURequestStepTag.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTag.js b/src/pages/iou/request/step/IOURequestStepTag.js index 18f8e68d67aa..fe44f91cda98 100644 --- a/src/pages/iou/request/step/IOURequestStepTag.js +++ b/src/pages/iou/request/step/IOURequestStepTag.js @@ -162,7 +162,18 @@ export default compose( key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, }, parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID || report.reportID : '0'}`, + key: ({ + report, + route: { + params: {action, iouType}, + }, + }) => { + let reportID = '0'; + if (action === CONST.IOU.ACTION.EDIT) { + reportID = iouType === CONST.IOU.TYPE.SPLIT ? report.reportID : report.parentReportID; + } + return `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`; + }, canEvict: false, }, session: { From 93aea8d68ea23860c1c3c4118875a7fcc24bb4fa Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 19:17:14 +0300 Subject: [PATCH 4/5] changed prop name --- src/pages/iou/request/step/IOURequestStepTag.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepTag.js b/src/pages/iou/request/step/IOURequestStepTag.js index fe44f91cda98..ffa764aa53d5 100644 --- a/src/pages/iou/request/step/IOURequestStepTag.js +++ b/src/pages/iou/request/step/IOURequestStepTag.js @@ -46,7 +46,7 @@ const propTypes = { policyTags: tagPropTypes, /** The actions from the parent report */ - parentReportActions: PropTypes.shape(reportActionPropTypes), + reportActions: PropTypes.shape(reportActionPropTypes), /** Session info for the currently logged in user. */ session: PropTypes.shape({ @@ -64,7 +64,7 @@ const defaultProps = { policyTags: null, policyCategories: null, transaction: {}, - parentReportActions: {}, + reportActions: {}, }; function IOURequestStepTag({ @@ -76,7 +76,7 @@ function IOURequestStepTag({ params: {action, tagIndex: rawTagIndex, transactionID, backTo, iouType, reportActionID}, }, transaction, - parentReportActions, + reportActions, session, }) { const styles = useThemeStyles(); @@ -88,11 +88,11 @@ function IOURequestStepTag({ const tag = TransactionUtils.getTag(transaction, tagIndex); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; - const parentReportAction = parentReportActions[report.parentReportActionID || reportActionID]; - const canEditSplitBill = isSplitBill && parentReportAction && session.accountID === parentReportAction.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction); + const reportAction = reportActions[report.parentReportActionID || reportActionID]; + const canEditSplitBill = isSplitBill && reportAction && session.accountID === reportAction.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction); // eslint-disable-next-line rulesdir/no-negated-variables - const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !canEditMoneyRequest(parentReportAction)); + const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !canEditMoneyRequest(reportAction)); const navigateBack = () => { Navigation.goBack(backTo); @@ -161,7 +161,7 @@ export default compose( policyTags: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, }, - parentReportActions: { + reportActions: { key: ({ report, route: { From 5717f246b5bcedff12c722e0cd26f462db8ac57c Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 19:38:26 +0300 Subject: [PATCH 5/5] change condition --- src/ROUTES.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index bca7bb81dbd5..0bdb77a3a360 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -394,7 +394,7 @@ const ROUTES = { reportID: string, backTo = '', reportActionID?: string, - ) => getUrlWithBackToParam(`${action}/${iouType}/tag/${tagIndex}/${transactionID}/${reportID}${typeof reportActionID === 'string' ? `/${reportActionID}` : ''}`, backTo), + ) => getUrlWithBackToParam(`${action}/${iouType}/tag/${tagIndex}/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), }, MONEY_REQUEST_STEP_WAYPOINT: { route: ':action/:iouType/waypoint/:transactionID/:reportID/:pageIndex',