From bbc32b2a1915f879eee97fc6b9c1070609100386 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 13 Sep 2023 16:16:01 +0200 Subject: [PATCH 1/5] feat: save participantAccountIDs for iou in Onyx --- src/libs/actions/IOU.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 5b79fb6ad4bb..098dbb6dbad7 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -88,7 +88,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, @@ -1888,7 +1890,8 @@ 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) + Onyx.merge(ONYXKEYS.IOU, {participants, participantAccountIDs: _.map(participants, 'accountID')}); } /** From 9d9ffb8c97e9e4d6b771d36b7211231e50fff183 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 13 Sep 2023 17:31:02 +0200 Subject: [PATCH 2/5] refactor: replace participants with participantAccountIDs where it's possible without additional changes --- src/pages/iou/MoneyRequestDatePage.js | 4 ++-- src/pages/iou/MoneyRequestDescriptionPage.js | 4 ++-- src/pages/iou/steps/NewRequestAmountPage.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/MoneyRequestDatePage.js b/src/pages/iou/MoneyRequestDatePage.js index 428a1a3b4593..68af1a6244b6 100644 --- a/src/pages/iou/MoneyRequestDatePage.js +++ b/src/pages/iou/MoneyRequestDatePage.js @@ -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)); diff --git a/src/pages/iou/MoneyRequestDescriptionPage.js b/src/pages/iou/MoneyRequestDescriptionPage.js index 0678088073d3..63aea67ce598 100644 --- a/src/pages/iou/MoneyRequestDescriptionPage.js +++ b/src/pages/iou/MoneyRequestDescriptionPage.js @@ -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)); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 0d154809cd4d..2b302f7a203e 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -115,7 +115,7 @@ 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); } } @@ -123,7 +123,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { 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); From c8e42e75d49a917468d04dd5b634612cdf70ae76 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 14 Sep 2023 08:36:35 +0200 Subject: [PATCH 3/5] refactor: replace paticipants for participantAccountIDs in merchant page --- src/pages/iou/MoneyRequestMerchantPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/MoneyRequestMerchantPage.js b/src/pages/iou/MoneyRequestMerchantPage.js index 9a49b0259bd2..1131f3deeda0 100644 --- a/src/pages/iou/MoneyRequestMerchantPage.js +++ b/src/pages/iou/MoneyRequestMerchantPage.js @@ -58,7 +58,7 @@ 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]); From 8c785f2b3a7fe017719333ee0b0902614c3e62dd Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 14 Sep 2023 09:30:33 +0200 Subject: [PATCH 4/5] fix: add missing dep --- src/pages/iou/MoneyRequestMerchantPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/MoneyRequestMerchantPage.js b/src/pages/iou/MoneyRequestMerchantPage.js index 1131f3deeda0..f8ae810eafba 100644 --- a/src/pages/iou/MoneyRequestMerchantPage.js +++ b/src/pages/iou/MoneyRequestMerchantPage.js @@ -61,7 +61,7 @@ function MoneyRequestMerchantPage({iou, route}) { 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)); From 48586741341266fc93c03219bc770a4b543e6222 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 14 Sep 2023 09:33:32 +0200 Subject: [PATCH 5/5] chore: add more info to the comment for setMoneyRequestParticipants --- src/libs/actions/IOU.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 098dbb6dbad7..ede5ed67cfd8 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1891,6 +1891,7 @@ function resetMoneyRequestCategory() { */ function setMoneyRequestParticipants(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')}); }