From 53f1893997a06acced1c838147ecd4c723f22c22 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 2 Jan 2024 19:50:28 +0100 Subject: [PATCH 1/3] fix: make merchant not required for p2p --- src/pages/iou/request/step/IOURequestStepMerchant.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.js b/src/pages/iou/request/step/IOURequestStepMerchant.js index 355bb76b89b0..89a77b19f8dd 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.js +++ b/src/pages/iou/request/step/IOURequestStepMerchant.js @@ -36,13 +36,15 @@ function IOURequestStepMerchant({ route: { params: {transactionID, backTo}, }, - transaction: {merchant}, + transaction: {merchant, participants}, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {inputCallbackRef} = useAutoFocusInput(); const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; + const isMerchantRequired = _.some(participants, participant => Boolean(participant.isPolicyExpenseChat)) + const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); }; @@ -54,12 +56,12 @@ function IOURequestStepMerchant({ const validate = useCallback((value) => { const errors = {}; - if (_.isEmpty(value.moneyRequestMerchant)) { + if (isMerchantRequired && _.isEmpty(value.moneyRequestMerchant)) { errors.moneyRequestMerchant = 'common.error.fieldRequired'; } return errors; - }, []); + }, [isMerchantRequired]); /** * @param {Object} value From ef63a21e29fca46c130e0c3631f75aa5c5353c18 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 2 Jan 2024 20:40:52 +0100 Subject: [PATCH 2/3] fix: prettier --- .../request/step/IOURequestStepMerchant.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.js b/src/pages/iou/request/step/IOURequestStepMerchant.js index 89a77b19f8dd..091e7d8023c3 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.js +++ b/src/pages/iou/request/step/IOURequestStepMerchant.js @@ -43,7 +43,7 @@ function IOURequestStepMerchant({ const {inputCallbackRef} = useAutoFocusInput(); const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const isMerchantRequired = _.some(participants, participant => Boolean(participant.isPolicyExpenseChat)) + const isMerchantRequired = _.some(participants, (participant) => Boolean(participant.isPolicyExpenseChat)); const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); @@ -53,15 +53,18 @@ function IOURequestStepMerchant({ * @param {Object} value * @param {String} value.moneyRequestMerchant */ - const validate = useCallback((value) => { - const errors = {}; + const validate = useCallback( + (value) => { + const errors = {}; - if (isMerchantRequired && _.isEmpty(value.moneyRequestMerchant)) { - errors.moneyRequestMerchant = 'common.error.fieldRequired'; - } + if (isMerchantRequired && _.isEmpty(value.moneyRequestMerchant)) { + errors.moneyRequestMerchant = 'common.error.fieldRequired'; + } - return errors; - }, [isMerchantRequired]); + return errors; + }, + [isMerchantRequired], + ); /** * @param {Object} value From e1e5d0312eebb88b5cc4c54a778b22f462fe3ba5 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 2 Jan 2024 20:50:32 +0100 Subject: [PATCH 3/3] fix: typo --- src/ROUTES.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 35fa4bbf0837..1663f0295b9e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -358,9 +358,9 @@ const ROUTES = { getUrlWithBackToParam(`create/${iouType}/distance/${transactionID}/${reportID}/`, backTo), }, MONEY_REQUEST_STEP_MERCHANT: { - route: 'create/:iouType/merchante/:transactionID/:reportID/', + route: 'create/:iouType/merchant/:transactionID/:reportID/', getRoute: (iouType: ValueOf, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`create/${iouType}/merchante/${transactionID}/${reportID}/`, backTo), + getUrlWithBackToParam(`create/${iouType}/merchant/${transactionID}/${reportID}/`, backTo), }, MONEY_REQUEST_STEP_PARTICIPANTS: { route: 'create/:iouType/participants/:transactionID/:reportID/',