Skip to content

Commit f903a08

Browse files
authored
Merge pull request Expensify#78925 from parasharrajat/onyx/66514-2
[Part 2] Remove Onyx.connect() for the key: ONYXKEYS.COLLECTION.NEXT_STEP in src/libs/actions/IOU.ts
2 parents b3a0e3d + 9f53cbb commit f903a08

5 files changed

Lines changed: 27 additions & 16 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ function MoneyReportHeader({
537537
paymentMethodType: type,
538538
chatReport,
539539
invoiceReport: moneyRequestReport,
540+
invoiceReportCurrentNextStepDeprecated: nextStep,
540541
introSelected,
541542
currentUserAccountIDParam: accountID,
542543
currentUserEmailParam: email ?? '',
@@ -548,7 +549,7 @@ function MoneyReportHeader({
548549
});
549550
} else {
550551
startAnimation();
551-
payMoneyRequest(type, chatReport, moneyRequestReport, introSelected, undefined, true, activePolicy, policy);
552+
payMoneyRequest(type, chatReport, moneyRequestReport, introSelected, nextStep, undefined, true, activePolicy, policy);
552553
if (currentSearchQueryJSON && !isOffline) {
553554
search({
554555
searchKey: currentSearchKey,
@@ -569,17 +570,18 @@ function MoneyReportHeader({
569570
showDelegateNoAccessModal,
570571
startAnimation,
571572
moneyRequestReport,
573+
nextStep,
572574
introSelected,
575+
accountID,
576+
email,
573577
existingB2BInvoiceReport,
574-
shouldCalculateTotals,
575578
activePolicy,
576579
policy,
577580
currentSearchQueryJSON,
578-
currentSearchKey,
579581
isOffline,
582+
currentSearchKey,
583+
shouldCalculateTotals,
580584
currentSearchResults?.search?.isLoading,
581-
accountID,
582-
email,
583585
],
584586
);
585587

src/components/ProcessMoneyReportHoldMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function ProcessMoneyReportHoldMenu({
9696
if (startAnimation) {
9797
startAnimation();
9898
}
99-
payMoneyRequest(paymentType, chatReport, moneyRequestReport, introSelected, undefined, full, activePolicy, policy);
99+
payMoneyRequest(paymentType, chatReport, moneyRequestReport, introSelected, moneyRequestReportNextStep, undefined, full, activePolicy, policy);
100100
}
101101
onClose();
102102
};

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ function MoneyRequestReportPreviewContent({
259259
paymentMethodType: type,
260260
chatReport,
261261
invoiceReport: iouReport,
262+
invoiceReportCurrentNextStepDeprecated: iouReportNextStep,
262263
introSelected,
263264
currentUserAccountIDParam: currentUserAccountID,
264265
currentUserEmailParam: currentUserEmail,
@@ -269,7 +270,7 @@ function MoneyRequestReportPreviewContent({
269270
activePolicy,
270271
});
271272
} else {
272-
payMoneyRequest(type, chatReport, iouReport, introSelected, undefined, true, activePolicy, policy);
273+
payMoneyRequest(type, chatReport, iouReport, introSelected, iouReportNextStep, undefined, true, activePolicy, policy);
273274
}
274275
}
275276
},
@@ -279,11 +280,12 @@ function MoneyRequestReportPreviewContent({
279280
chatReport,
280281
showDelegateNoAccessModal,
281282
startAnimation,
283+
iouReportNextStep,
282284
introSelected,
283-
existingB2BInvoiceReport,
284-
activePolicy,
285285
currentUserAccountID,
286286
currentUserEmail,
287+
existingB2BInvoiceReport,
288+
activePolicy,
287289
policy,
288290
],
289291
);

src/libs/actions/IOU/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ type PayInvoiceArgs = {
320320
chatReport: OnyxTypes.Report;
321321
invoiceReport: OnyxEntry<OnyxTypes.Report>;
322322
introSelected: OnyxEntry<OnyxTypes.IntroSelected>;
323+
invoiceReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
323324
currentUserAccountIDParam: number;
324325
currentUserEmailParam: string;
325326
payAsBusiness?: boolean;
@@ -9404,6 +9405,7 @@ function getPayMoneyRequestParams({
94049405
lastUsedPaymentMethod,
94059406
existingB2BInvoiceReport,
94069407
activePolicy,
9408+
iouReportCurrentNextStepDeprecated,
94079409
}: {
94089410
initialChatReport: OnyxTypes.Report;
94099411
iouReport: OnyxEntry<OnyxTypes.Report>;
@@ -9420,6 +9422,7 @@ function getPayMoneyRequestParams({
94209422
currentUserAccountIDParam?: number;
94219423
currentUserEmailParam?: string;
94229424
introSelected?: OnyxEntry<OnyxTypes.IntroSelected>;
9425+
iouReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
94239426
}): PayMoneyRequestData {
94249427
const isInvoiceReport = isInvoiceReportReportUtils(iouReport);
94259428
let payerPolicyID = activePolicy?.id;
@@ -9499,7 +9502,7 @@ function getPayMoneyRequestParams({
94999502
let optimisticNextStepDeprecated = null;
95009503
let optimisticNextStep = null;
95019504
if (!isInvoiceReport) {
9502-
currentNextStepDeprecated = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`] ?? null;
9505+
currentNextStepDeprecated = iouReportCurrentNextStepDeprecated ?? null;
95039506
// buildOptimisticNextStep is used in parallel
95049507
// eslint-disable-next-line @typescript-eslint/no-deprecated
95059508
optimisticNextStepDeprecated = buildNextStepNew({report: iouReport, predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED});
@@ -11163,6 +11166,7 @@ function payMoneyRequest(
1116311166
chatReport: OnyxTypes.Report,
1116411167
iouReport: OnyxEntry<OnyxTypes.Report>,
1116511168
introSelected: OnyxEntry<OnyxTypes.IntroSelected>,
11169+
iouReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>,
1116611170
paymentPolicyID?: string,
1116711171
full = true,
1116811172
activePolicy?: OnyxEntry<OnyxTypes.Policy>,
@@ -11186,6 +11190,7 @@ function payMoneyRequest(
1118611190
paymentPolicyID,
1118711191
activePolicy,
1118811192
reportPolicy: policy,
11193+
iouReportCurrentNextStepDeprecated,
1118911194
});
1119011195

1119111196
// For now, we need to call the PayMoneyRequestWithWallet API since PayMoneyRequest was not updated to work with
@@ -11210,6 +11215,7 @@ function payInvoice({
1121011215
methodID,
1121111216
paymentMethod,
1121211217
activePolicy,
11218+
invoiceReportCurrentNextStepDeprecated,
1121311219
}: PayInvoiceArgs) {
1121411220
const recipient = {accountID: invoiceReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID};
1121511221
const {
@@ -11231,6 +11237,7 @@ function payInvoice({
1123111237
} = getPayMoneyRequestParams({
1123211238
initialChatReport: chatReport,
1123311239
iouReport: invoiceReport,
11240+
iouReportCurrentNextStepDeprecated: invoiceReportCurrentNextStepDeprecated,
1123411241
recipient,
1123511242
paymentMethodType,
1123611243
full: true,

tests/actions/IOUTest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,7 +3928,7 @@ describe('actions/IOU', () => {
39283928
.then(() => {
39293929
mockFetch?.pause?.();
39303930
if (chatReport && iouReport) {
3931-
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined);
3931+
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined);
39323932
}
39333933
return waitForBatchedUpdates();
39343934
})
@@ -4299,7 +4299,7 @@ describe('actions/IOU', () => {
42994299
jest.advanceTimersByTime(10);
43004300

43014301
// When paying the IOU report
4302-
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined);
4302+
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined);
43034303

43044304
await waitForBatchedUpdates();
43054305

@@ -4401,7 +4401,7 @@ describe('actions/IOU', () => {
44014401
})
44024402
.then(() => {
44034403
// When partially paying an iou report from the chat report via the report preview
4404-
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, {reportID: topMostReportID}, iouReport, undefined, undefined, false);
4404+
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, {reportID: topMostReportID}, iouReport, undefined, undefined, undefined, false);
44054405
return waitForBatchedUpdates();
44064406
})
44074407
.then(() => {
@@ -4483,7 +4483,7 @@ describe('actions/IOU', () => {
44834483
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, expenseReport);
44844484
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, chatReport);
44854485

4486-
const newExpenseReportID = payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined, false, undefined, policy);
4486+
const newExpenseReportID = payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined, undefined, false, undefined, policy);
44874487
await waitForBatchedUpdates();
44884488
const newExpenseReport = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}${newExpenseReportID}`);
44894489
expect(newExpenseReport?.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN);
@@ -4569,7 +4569,7 @@ describe('actions/IOU', () => {
45694569
.then(() => {
45704570
// When the expense report is paid elsewhere (but really, any payment option would work)
45714571
if (chatReport && expenseReport) {
4572-
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined);
4572+
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined);
45734573
}
45744574
return waitForBatchedUpdates();
45754575
})
@@ -8269,7 +8269,7 @@ describe('actions/IOU', () => {
82698269
// When the expense report is paid elsewhere (but really, any payment option would work)
82708270
if (chatReport && expenseReport) {
82718271
mockFetch?.pause?.();
8272-
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined);
8272+
payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined);
82738273
}
82748274
await waitForBatchedUpdates();
82758275

0 commit comments

Comments
 (0)