From 83f1080977513c885c0481a35914ed26aa6f8389 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 1 Dec 2025 15:54:29 +0700 Subject: [PATCH 1/6] Using buildOptimisticNextStep parallel --- src/libs/actions/IOU.ts | 116 ++++++++++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 249f750e184e..6ab92766faf6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -251,7 +251,7 @@ import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type RecentlyUsedTags from '@src/types/onyx/RecentlyUsedTags'; -import type {InvoiceReceiver, InvoiceReceiverType} from '@src/types/onyx/Report'; +import type {InvoiceReceiver, InvoiceReceiverType, ReportNextStep} from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {OnyxData} from '@src/types/onyx/Request'; import type {SearchTransaction} from '@src/types/onyx/SearchResults'; @@ -570,7 +570,8 @@ type MoneyRequestOptimisticParams = { destinations?: string[]; }; personalDetailListAction?: OnyxTypes.PersonalDetailsList; - nextStep?: OnyxTypes.ReportNextStepDeprecated | null; + nextStepDeprecated?: OnyxTypes.ReportNextStepDeprecated | null; + nextStep?: ReportNextStep | null; testDriveCommentReportActionID?: string; }; @@ -1604,6 +1605,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR policyRecentlyUsed, personalDetailListAction, nextStep, + nextStepDeprecated, testDriveCommentReportActionID, } = optimisticParams; @@ -1647,12 +1649,34 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR }); } + const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( + transaction, + [], + policy, + policyTagList ?? {}, + policyCategories ?? {}, + hasDependentTags(policy, policyTagList ?? {}), + false, + ); + const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0; + const optimisticNextStep = buildOptimisticNextStep({ + report: iou.report, + predictedNextStatus: iou.report.statusNum ?? CONST.REPORT.STATE_NUM.OPEN, + shouldFixViolations, + policy, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + }); + optimisticData.push( { onyxMethod: shouldCreateNewMoneyRequestReport ? Onyx.METHOD.SET : Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, value: { ...iou.report, + nextStep: violationsOnyxData ? optimisticNextStep : undefined, lastVisibleActionCreated: iou.action.created, pendingFields: { ...(shouldCreateNewMoneyRequestReport ? {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD} : {preview: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), @@ -1827,6 +1851,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR ...iou.report, ...(!isScanRequest || isTestReceipt ? {lastActionType: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED} : undefined), hasOutstandingChildRequest: false, + nextStep: !isEmptyObject(nextStep) ? nextStep : undefined, lastActorAccountID: deprecatedCurrentUserPersonalDetails?.accountID, }, }, @@ -1872,11 +1897,12 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR }); } - if (!isEmptyObject(nextStep)) { + // buildOptimisticNextStep is used in parallel + if (!isEmptyObject(nextStepDeprecated)) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`, - value: nextStep, + value: nextStepDeprecated, }); } @@ -2152,22 +2178,13 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR return [optimisticData, successData, failureData]; } - const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( - transaction, - [], - policy, - policyTagList ?? {}, - policyCategories ?? {}, - hasDependentTags(policy, policyTagList ?? {}), - false, - ); - if (violationsOnyxData) { const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0; optimisticData.push(violationsOnyxData, { key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`, onyxMethod: Onyx.METHOD.SET, + // buildOptimisticNextStep is used in parallel // eslint-disable-next-line @typescript-eslint/no-deprecated value: buildNextStepNew({ report: iou.report, @@ -3680,8 +3697,19 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma const predictedNextStatus = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.OPEN; const hasViolations = hasViolationsReportUtils(iouReport.reportID, transactionViolations); + // buildOptimisticNextStep is used in parallel // eslint-disable-next-line @typescript-eslint/no-deprecated - const optimisticNextStep = buildNextStepNew({ + const optimisticNextStepDeprecated = buildNextStepNew({ + report: iouReport, + predictedNextStatus, + policy, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + }); + + const optimisticNextStep = buildOptimisticNextStep({ report: iouReport, predictedNextStatus, policy, @@ -3724,6 +3752,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma currencies: optimisticPolicyRecentlyUsedCurrencies, }, personalDetailListAction: optimisticPersonalDetailListAction, + nextStepDeprecated: optimisticNextStepDeprecated, nextStep: optimisticNextStep, testDriveCommentReportActionID, }, @@ -3962,8 +3991,26 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI : {}; const predictedNextStatus = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.OPEN; + // buildOptimisticNextStep is used in parallel // eslint-disable-next-line @typescript-eslint/no-deprecated - const optimisticNextStep = buildNextStepNew({report: iouReport, predictedNextStatus, currentUserAccountIDParam, currentUserEmailParam, hasViolations, isASAPSubmitBetaEnabled, policy}); + const optimisticNextStepDeprecated = buildNextStepNew({ + report: iouReport, + predictedNextStatus, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + policy, + }); + const optimisticNextStep = buildOptimisticNextStep({ + report: iouReport, + predictedNextStatus, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + policy, + }); // STEP 5: Build Onyx Data const [optimisticData, successData, failureData] = buildOnyxDataForMoneyRequest({ @@ -3999,6 +4046,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI }, personalDetailListAction: optimisticPersonalDetailListAction, nextStep: optimisticNextStep, + nextStepDeprecated: optimisticNextStepDeprecated, }, currentUserAccountIDParam, currentUserEmailParam, @@ -4800,9 +4848,20 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0; const moneyRequestReport = updatedMoneyRequestReport ?? iouReport ?? undefined; const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, allTransactionViolations); + const optimisticNextStep = buildOptimisticNextStep({ + report: moneyRequestReport, + predictedNextStatus: iouReport?.statusNum ?? CONST.REPORT.STATUS_NUM.OPEN, + shouldFixViolations, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + policy, + }); optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`, + // buildOptimisticNextStep is used in parallel // eslint-disable-next-line @typescript-eslint/no-deprecated value: buildNextStepNew({ report: moneyRequestReport, @@ -4815,11 +4874,25 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U policy, }), }); + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, + value: { + nextStep: optimisticNextStep, + }, + }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`, value: currentNextStep, }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, + value: { + nextStep: iouReport?.nextStep, + }, + }); } } @@ -11615,12 +11688,23 @@ function cancelPayment( failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`, + // buildOptimisticNextStep is used in parallel // eslint-disable-next-line @typescript-eslint/no-deprecated value: buildNextStepNew({ report: expenseReport, predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED, }), }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, + value: { + nextStep: buildOptimisticNextStep({ + report: expenseReport, + predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED, + }), + }, + }); API.write( WRITE_COMMANDS.CANCEL_PAYMENT, From fb7dd305ad2b913b5998146199be5bcd236147db Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 1 Dec 2025 16:08:38 +0700 Subject: [PATCH 2/6] using buildOptimisticNextStep --- src/libs/actions/IOU.ts | 50 ++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6ab92766faf6..5591aea2d812 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1649,34 +1649,12 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR }); } - const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( - transaction, - [], - policy, - policyTagList ?? {}, - policyCategories ?? {}, - hasDependentTags(policy, policyTagList ?? {}), - false, - ); - const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0; - const optimisticNextStep = buildOptimisticNextStep({ - report: iou.report, - predictedNextStatus: iou.report.statusNum ?? CONST.REPORT.STATE_NUM.OPEN, - shouldFixViolations, - policy, - currentUserAccountIDParam, - currentUserEmailParam, - hasViolations, - isASAPSubmitBetaEnabled, - }); - optimisticData.push( { onyxMethod: shouldCreateNewMoneyRequestReport ? Onyx.METHOD.SET : Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, value: { ...iou.report, - nextStep: violationsOnyxData ? optimisticNextStep : undefined, lastVisibleActionCreated: iou.action.created, pendingFields: { ...(shouldCreateNewMoneyRequestReport ? {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD} : {preview: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), @@ -2177,10 +2155,28 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR if (!policy || !isPaidGroupPolicy(policy) || transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) { return [optimisticData, successData, failureData]; } + const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( + transaction, + [], + policy, + policyTagList ?? {}, + policyCategories ?? {}, + hasDependentTags(policy, policyTagList ?? {}), + false, + ); if (violationsOnyxData) { const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0; - + const optimisticNextStep = buildOptimisticNextStep({ + report: iou.report, + predictedNextStatus: iou.report.statusNum ?? CONST.REPORT.STATE_NUM.OPEN, + shouldFixViolations, + policy, + currentUserAccountIDParam, + currentUserEmailParam, + hasViolations, + isASAPSubmitBetaEnabled, + }); optimisticData.push(violationsOnyxData, { key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`, onyxMethod: Onyx.METHOD.SET, @@ -2197,6 +2193,14 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR isASAPSubmitBetaEnabled, }), }); + optimisticData.push({ + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + onyxMethod: Onyx.METHOD.MERGE, + value: { + nextStep: optimisticNextStep, + }, + }); + failureData.push({ onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, From 9e1755198fb399a745875f3ce8320eb29f4b3626 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 2 Dec 2025 14:56:46 +0700 Subject: [PATCH 3/6] resolve comment --- src/libs/actions/IOU.ts | 45 ++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5591aea2d812..c17083da1c85 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1829,7 +1829,6 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR ...iou.report, ...(!isScanRequest || isTestReceipt ? {lastActionType: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED} : undefined), hasOutstandingChildRequest: false, - nextStep: !isEmptyObject(nextStep) ? nextStep : undefined, lastActorAccountID: deprecatedCurrentUserPersonalDetails?.accountID, }, }, @@ -1875,13 +1874,22 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR }); } - // buildOptimisticNextStep is used in parallel if (!isEmptyObject(nextStepDeprecated)) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`, value: nextStepDeprecated, }); + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + value: { + nextStep: nextStep, + pendingFields: { + nextStep: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + }); } if (isNewChatReport) { @@ -4883,6 +4891,9 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, value: { nextStep: optimisticNextStep, + pendingFields: { + nextStep: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }); failureData.push({ @@ -4894,7 +4905,19 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, value: { - nextStep: iouReport?.nextStep, + nextStep: iouReport?.nextStep ?? null, + pendingFields: { + nextStep: null, + }, + }, + }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, + value: { + pendingFields: { + nextStep: null, + }, }, }); } @@ -11640,7 +11663,11 @@ function cancelPayment( statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, isWaitingOnBankAccount: expenseReport.isWaitingOnBankAccount, isCancelledIOU: false, - nextStep: expenseReport.nextStep ?? null, + nextStep: + buildOptimisticNextStep({ + report: expenseReport, + predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED, + }) ?? null, pendingFields: { nextStep: null, }, @@ -11699,16 +11726,6 @@ function cancelPayment( predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED, }), }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, - value: { - nextStep: buildOptimisticNextStep({ - report: expenseReport, - predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED, - }), - }, - }); API.write( WRITE_COMMANDS.CANCEL_PAYMENT, From f4c166709501c9d6647cbaec37eef1de5a41f4c9 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 2 Dec 2025 15:12:45 +0700 Subject: [PATCH 4/6] fix eslint and failed type on main --- src/libs/actions/IOU.ts | 4 ++-- tests/unit/ReportPrimaryActionUtilsTest.ts | 1 + tests/unit/ReportSecondaryActionUtilsTest.ts | 11 ++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 45db49a81f1d..d49eb4be043e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1887,7 +1887,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, value: { - nextStep: nextStep, + nextStep, pendingFields: { nextStep: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -3717,8 +3717,8 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma const predictedNextStatus = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.OPEN; const hasViolations = hasViolationsReportUtils(iouReport.reportID, transactionViolations, currentUserAccountIDParam, currentUserEmailParam); - // eslint-disable-next-line @typescript-eslint/no-deprecated // buildOptimisticNextStep is used in parallel + // eslint-disable-next-line @typescript-eslint/no-deprecated const optimisticNextStepDeprecated = buildNextStepNew({ report: iouReport, predictedNextStatus, diff --git a/tests/unit/ReportPrimaryActionUtilsTest.ts b/tests/unit/ReportPrimaryActionUtilsTest.ts index 1951008939df..942902838bfb 100644 --- a/tests/unit/ReportPrimaryActionUtilsTest.ts +++ b/tests/unit/ReportPrimaryActionUtilsTest.ts @@ -682,6 +682,7 @@ describe('getPrimaryAction', () => { expect( getReportPrimaryAction({ currentUserEmail: CURRENT_USER_EMAIL, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, report, chatReport, reportTransactions: [transaction], diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index a85221e5c409..865e19f2e4f5 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -1641,7 +1641,16 @@ describe('getSecondaryAction', () => { jest.spyOn(ReportActionsUtils, 'getOneTransactionThreadReportID').mockReturnValue(originalMessageR14932.IOUTransactionID); jest.spyOn(ReportUtils, 'isHoldCreator').mockReturnValue(false); - const result = getSecondaryReportActions({currentUserEmail: EMPLOYEE_EMAIL, report, chatReport, reportTransactions, originalTransaction: {} as Transaction, violations: {}, policy}); + const result = getSecondaryReportActions({ + currentUserEmail: EMPLOYEE_EMAIL, + currentUserAccountID: EMPLOYEE_ACCOUNT_ID, + report, + chatReport, + reportTransactions, + originalTransaction: {} as Transaction, + violations: {}, + policy, + }); expect(result).not.toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD); }); }); From 6d089354aebabe30aa54f38a53074bcd74761be7 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 2 Dec 2025 15:30:42 +0700 Subject: [PATCH 5/6] reset pendingFields --- src/libs/actions/IOU.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index d49eb4be043e..ca655cb48ef6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1883,6 +1883,8 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`, value: nextStepDeprecated, }); + } + if (!isEmptyObject(nextStep)) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, @@ -1893,6 +1895,24 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR }, }, }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + value: { + pendingFields: { + nextStep: null, + }, + }, + }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + value: { + pendingFields: { + nextStep: null, + }, + }, + }); } if (isNewChatReport) { From b520091391d57c8b9631f63c1c43da9c2181233f Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 15 Dec 2025 14:44:50 +0700 Subject: [PATCH 6/6] address comments --- src/libs/actions/IOU.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 1b28c48390e0..afeacae1ce53 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1927,6 +1927,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, value: { + nextStep: iou.report.nextStep ?? null, pendingFields: { nextStep: null, }, @@ -2232,14 +2233,35 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR onyxMethod: Onyx.METHOD.MERGE, value: { nextStep: optimisticNextStep, + pendingFields: { + nextStep: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + value: { + pendingFields: { + nextStep: null, + }, }, }); - failureData.push({ onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, value: [], }); + failureData.push({ + key: `${ONYXKEYS.COLLECTION.REPORT}${iou.report.reportID}`, + onyxMethod: Onyx.METHOD.MERGE, + value: { + nextStep: iou.report.nextStep ?? null, + pendingFields: { + nextStep: null, + }, + }, + }); } return [optimisticData, successData, failureData];