Skip to content

Commit

Permalink
Merge pull request #29936 from DylanDylann/fix/28751
Browse files Browse the repository at this point in the history
Update request money header title
  • Loading branch information
amyevans authored Oct 27, 2023
2 parents 93d7191 + d4bce78 commit b529f96
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function resetMoneyRequestInfo(id = '') {
receiptFilename: '',
transactionID: '',
billable: null,
isSplitRequest: false,
});
}

Expand Down Expand Up @@ -2863,9 +2864,10 @@ function setMoneyRequestBillable(billable) {

/**
* @param {Object[]} participants
* @param {Boolean} isSplitRequest
*/
function setMoneyRequestParticipants(participants) {
Onyx.merge(ONYXKEYS.IOU, {participants});
function setMoneyRequestParticipants(participants, isSplitRequest) {
Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest});
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ function MoneyRequestConfirmPage(props) {
return props.translate('common.send');
}

if (isScanRequest) {
return props.translate('tabSelector.scan');
}

return props.translate('tabSelector.manual');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import CONST from '../../../../CONST';
import ONYXKEYS from '../../../../ONYXKEYS';
import ROUTES from '../../../../ROUTES';
Expand Down Expand Up @@ -67,8 +66,13 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
return;
}

setHeaderTitle(_.isEmpty(iou.participants) ? translate('tabSelector.manual') : translate('iou.split'));
}, [iou.participants, isDistanceRequest, isSendRequest, translate]);
if (isScanRequest) {
setHeaderTitle(translate('tabSelector.scan'));
return;
}

setHeaderTitle(iou.isSplitRequest ? translate('iou.split') : translate('tabSelector.manual'));
}, [iou.isSplitRequest, isDistanceRequest, translate, isScanRequest, isSendRequest]);

const navigateToConfirmationStep = (moneyRequestType) => {
IOU.setMoneyRequestId(moneyRequestType);
Expand Down Expand Up @@ -120,7 +124,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
/>
<MoneyRequestParticipantsSelector
ref={(el) => (optionsSelectorRef.current = el)}
participants={iou.participants}
participants={iou.isSplitRequest ? iou.participants : []}
onAddParticipants={IOU.setMoneyRequestParticipants}
navigateToRequest={() => navigateToConfirmationStep(iouType)}
navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.TYPE.SPLIT)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ function MoneyRequestParticipantsSelector({
* @param {Object} option
*/
const addSingleParticipant = (option) => {
onAddParticipants([
{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText},
]);
onAddParticipants(
[{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText}],
false,
);
navigateToRequest();
};

Expand Down Expand Up @@ -198,8 +199,7 @@ function MoneyRequestParticipantsSelector({
},
];
}

onAddParticipants(newSelectedOptions);
onAddParticipants(newSelectedOptions, newSelectedOptions.length !== 0);
},
[participants, onAddParticipants],
);
Expand Down

0 comments on commit b529f96

Please sign in to comment.