Skip to content

Commit

Permalink
Merge pull request #33844 from koko57/fix/33789-merchant-not-required…
Browse files Browse the repository at this point in the history
…-for-p2p
  • Loading branch information
mountiny authored Jan 5, 2024
2 parents 2d455bf + e1e5d03 commit 6fad557
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.IOU.TYPE>, 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/',
Expand Down
21 changes: 13 additions & 8 deletions src/pages/iou/request/step/IOURequestStepMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand All @@ -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
Expand Down

0 comments on commit 6fad557

Please sign in to comment.