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/', diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.js b/src/pages/iou/request/step/IOURequestStepMerchant.js index 355bb76b89b0..091e7d8023c3 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); }; @@ -51,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 (_.isEmpty(value.moneyRequestMerchant)) { - errors.moneyRequestMerchant = 'common.error.fieldRequired'; - } + if (isMerchantRequired && _.isEmpty(value.moneyRequestMerchant)) { + errors.moneyRequestMerchant = 'common.error.fieldRequired'; + } - return errors; - }, []); + return errors; + }, + [isMerchantRequired], + ); /** * @param {Object} value