Skip to content

Commit

Permalink
Merge pull request #27369 from koko57/refactor/25714-replace-particip…
Browse files Browse the repository at this point in the history
…ants-with-participantAccountIDs

Refactor/25714 replace participants with participantAccountIDs
  • Loading branch information
puneetlath authored Sep 15, 2023
2 parents 2427a06 + 64dc712 commit 83b3f5d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ function resetMoneyRequestInfo(id = '') {
amount: 0,
currency: lodashGet(currentUserPersonalDetails, 'localCurrencyCode', CONST.CURRENCY.USD),
comment: '',
// TODO: remove participants after all instances of iou.participants will be replaced with iou.participantAccountIDs
participants: [],
participantAccountIDs: [],
merchant: CONST.TRANSACTION.DEFAULT_MERCHANT,
category: '',
created,
Expand Down Expand Up @@ -1950,7 +1952,9 @@ function resetMoneyRequestCategory() {
* @param {Object[]} participants
*/
function setMoneyRequestParticipants(participants) {
Onyx.merge(ONYXKEYS.IOU, {participants});
// TODO: temporarily we want to save both participants and participantAccountIDs, then we can remove participants (and rename the function)
// more info: https://github.com/Expensify/App/issues/25714#issuecomment-1712924903 and https://github.com/Expensify/App/issues/25714#issuecomment-1716335802
Onyx.merge(ONYXKEYS.IOU, {participants, participantAccountIDs: _.map(participants, 'accountID')});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/MoneyRequestDatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ function MoneyRequestDatePage({iou, route, selectedTab}) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}

if (!isDistanceRequest && (_.isEmpty(iou.participants) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
if (!isDistanceRequest && (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true);
}
}, [iou.id, iou.participants, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]);
}, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]);

function navigateBack() {
Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID));
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/MoneyRequestDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ function MoneyRequestDescriptionPage({iou, route, selectedTab}) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}

if (!isDistanceRequest && (_.isEmpty(iou.participants) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
if (!isDistanceRequest && (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true);
}
}, [iou.id, iou.participants, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]);
}, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]);

function navigateBack() {
Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID));
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/MoneyRequestMerchantPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ function MoneyRequestMerchantPage({iou, route}) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}

if (_.isEmpty(iou.participants) || (iou.amount === 0 && !iou.receiptPath) || shouldReset) {
if (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset) {
Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true);
}
}, [iou.id, iou.participants, iou.amount, iou.receiptPath, iouType, reportID]);
}, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID]);

function navigateBack() {
Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID));
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/steps/NewRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) {
IOU.resetMoneyRequestInfo(moneyRequestID);
}

if (!isDistanceRequestTab && (_.isEmpty(iou.participants) || iou.amount === 0 || shouldReset)) {
if (!isDistanceRequestTab && (_.isEmpty(iou.participantAccountIDs) || iou.amount === 0 || shouldReset)) {
Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true);
}
}

return () => {
prevMoneyRequestID.current = iou.id;
};
}, [iou.participants, iou.amount, iou.id, isEditing, iouType, reportID, isDistanceRequestTab]);
}, [iou.participantAccountIDs, iou.amount, iou.id, isEditing, iouType, reportID, isDistanceRequestTab]);

const navigateBack = () => {
Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : null);
Expand Down

0 comments on commit 83b3f5d

Please sign in to comment.