Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2157fe9
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Nov 1, 2025
8a7d581
Merge branch 'main' into fix/73390
dmkt9 Nov 4, 2025
62babf5
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Nov 4, 2025
94aa782
Merge branch 'Expensify:main' into fix/73390-2
dmkt9 Nov 4, 2025
c9fefcb
Merge branch 'main' into fix/73390-2
dmkt9 Nov 17, 2025
4005b5f
Merge branch 'main' into fix/73390-2
dmkt9 Jan 8, 2026
6695e9a
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 8, 2026
06ae95e
Merge branch 'main' into fix/73390-2
dmkt9 Jan 8, 2026
492aa9b
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 8, 2026
efda2e6
fix lint
dmkt9 Jan 8, 2026
88e019d
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 8, 2026
3f29df3
Merge branch 'main' into fix/73390-2
dmkt9 Jan 9, 2026
8c23289
Merge branch 'main' into fix/73390-2
dmkt9 Jan 9, 2026
5cc8441
Add unit tests - The "Reply" hyperlink below the expense preview is s…
dmkt9 Jan 10, 2026
7f267c3
fix lint
dmkt9 Jan 10, 2026
55d7c17
Merge branch 'main' into fix/73390-2
dmkt9 Jan 13, 2026
9baa185
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 13, 2026
906843a
fix ts and lint
dmkt9 Jan 13, 2026
74aaff4
Merge branch 'main' into fix/73390-2
dmkt9 Jan 14, 2026
12fe350
Merge branch 'main' into fix/73390-2
dmkt9 Jan 15, 2026
3fab5bb
fix lint
dmkt9 Jan 15, 2026
1a88456
Merge branch 'main' into fix/73390-2
dmkt9 Jan 16, 2026
926858e
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 16, 2026
f4d3291
fix lint
dmkt9 Jan 16, 2026
15ae161
Merge branch 'main' into fix/73390-2
dmkt9 Jan 25, 2026
4e65524
Fix - The "Reply" hyperlink below the expense preview is shown
dmkt9 Jan 25, 2026
c2d4c02
fix ts
dmkt9 Jan 25, 2026
76c5aa5
Merge branch 'main' into fix/73390-2
dmkt9 Feb 4, 2026
0cb91f7
fix ts
dmkt9 Feb 4, 2026
241205a
fix prettier
dmkt9 Feb 4, 2026
0ac32d3
Merge branch 'main' into fix/73390-2
dmkt9 Feb 4, 2026
d57f4fb
fix ts
dmkt9 Feb 4, 2026
679aefc
Remove the changes to split transactions
dmkt9 Feb 4, 2026
242d666
Merge branch 'main' into fix/73390-2
dmkt9 Feb 5, 2026
f22676b
fix test
dmkt9 Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
getAllReports,
getAllTransactions,
getAllTransactionViolations,
getCleanUpTransactionThreadReportOnyxData,
getCurrentUserEmail,
getMoneyRequestParticipantsFromReport,
getPolicyTags,
Expand Down Expand Up @@ -202,6 +203,25 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
}, {}),
};

const cleanUpTransactionThreadReportsOptimisticData = [];
const cleanUpTransactionThreadReportsSuccessData = [];
const cleanUpTransactionThreadReportsFailureData = [];
let updatedReportPreviewAction;
for (const [index, iouAction] of Object.entries(iouActionsToDelete)) {
const transactionThreadID = iouAction.childReportID;
const shouldDeleteTransactionThread = !!transactionThreadID;
const cleanUpTransactionThreadReportOnyxDataForIouAction = getCleanUpTransactionThreadReportOnyxData({
transactionThreadID,
shouldDeleteTransactionThread,
reportAction: iouAction,
updatedReportPreviewAction,
shouldAddUpdatedReportPreviewActionToOnyxData: Number(index) === iouActionsToDelete.length - 1,
Comment thread
dmkt9 marked this conversation as resolved.
Resolved
});
cleanUpTransactionThreadReportsOptimisticData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.optimisticData);
cleanUpTransactionThreadReportsSuccessData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.successData);
cleanUpTransactionThreadReportsFailureData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.failureData);
updatedReportPreviewAction = cleanUpTransactionThreadReportOnyxDataForIouAction.updatedReportPreviewAction;
}
const optimisticReportAction = buildOptimisticResolvedDuplicatesReportAction();

const transactionThreadReportID =
Expand All @@ -224,7 +244,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread

const optimisticData: OnyxUpdate[] = [];
const failureData: OnyxUpdate[] = [];
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS | typeof ONYXKEYS.COLLECTION.REPORT>> = [];

optimisticData.push(
optimisticTransactionData,
Expand All @@ -233,14 +253,17 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
expenseReportOptimisticData,
expenseReportActionsOptimisticData,
optimisticReportActionData,
...cleanUpTransactionThreadReportsOptimisticData,
);
successData.push(...cleanUpTransactionThreadReportsSuccessData);
failureData.push(
failureTransactionData,
...failureTransactionDuplicatesData,
...failureTransactionViolations,
expenseReportFailureData,
expenseReportActionsFailureData,
failureReportActionData,
...cleanUpTransactionThreadReportsFailureData,
);

if (optimisticTransactionThreadReportID) {
Expand Down
248 changes: 162 additions & 86 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
prepareOnboardingOnyxData,
shouldCreateNewMoneyRequestReport as shouldCreateNewMoneyRequestReportReportUtils,
shouldEnableNegative,
updateOptimisticParentReportAction,
updateReportPreview,
} from '@libs/ReportUtils';
import {buildCannedSearchQuery, getCurrentSearchQueryJSON} from '@libs/SearchQueryUtils';
Expand Down Expand Up @@ -788,7 +789,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 792 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -882,7 +883,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 886 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -896,7 +897,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 900 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -905,7 +906,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 909 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -919,7 +920,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 923 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -932,7 +933,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 936 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -941,7 +942,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 945 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -951,7 +952,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 955 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -960,7 +961,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 964 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -968,7 +969,7 @@
});

let allReportActions: OnyxCollection<OnyxTypes.ReportActions>;
Onyx.connect({

Check warning on line 972 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -2976,15 +2977,11 @@
const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
const transactionThreadID = reportAction.childReportID;
let transactionThread = null;
if (transactionThreadID) {
transactionThread = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`] ?? null;
}

// STEP 2: Decide if we need to:
// 1. Delete the transactionThread - delete if there are no visible comments in the thread and we're not moving the transaction
// 1. Delete the transactionThread - delete if we're not moving the transaction
// 2. Update the moneyRequestPreview to show [Deleted expense] - update if the transactionThread exists AND it isn't being deleted and we're not moving the transaction
const shouldDeleteTransactionThread = !isMovingTransactionFromTrackExpense && (transactionThreadID ? (reportAction?.childVisibleActionCount ?? 0) === 0 : false);
const shouldDeleteTransactionThread = !isMovingTransactionFromTrackExpense && !!transactionThreadID;

const shouldShowDeletedRequestMessage = !isMovingTransactionFromTrackExpense && !!transactionThreadID && !shouldDeleteTransactionThread;

Expand Down Expand Up @@ -3044,31 +3041,11 @@
value: null,
});

if (shouldDeleteTransactionThread) {
optimisticData.push(
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear.
// The remaining parts of the report object will be removed after the API call is successful.
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: {
reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
participants: {
[userAccountID]: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`,
value: null,
},
);
}
const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({
transactionThreadID,
shouldDeleteTransactionThread,
});
Comment thread
dmkt9 marked this conversation as resolved.
Resolved
optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData);

optimisticData.push(
{
Expand Down Expand Up @@ -3102,13 +3079,7 @@

// Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response.
// This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function.
if (shouldDeleteTransactionThread && transactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: null,
});
}
successData.push(...cleanUpTransactionThreadReportOnyxData.successData);

const failureData: Array<
OnyxUpdate<typeof ONYXKEYS.COLLECTION.TRANSACTION | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS | typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>
Expand Down Expand Up @@ -3137,13 +3108,7 @@
value: transactionViolations ?? null,
});

if (shouldDeleteTransactionThread) {
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: transactionThread,
});
}
failureData.push(...cleanUpTransactionThreadReportOnyxData.failureData);

if (actionableWhisperReportActionID) {
const actionableWhisperReportAction = getReportAction(chatReportID, actionableWhisperReportActionID);
Expand Down Expand Up @@ -8525,6 +8490,152 @@
});
}

/**
* @param transactionThreadID - The transaction thread reportID of the transaction
* @param shouldDeleteTransactionThread - Flag indicating whether the transactionThread should be optimistically deleted
* @param reportAction - The IOU action of the transaction
* @return Returns Onyx data including information about deleting the transactionThread and updating the child comment count for the preview report action
*/
function getCleanUpTransactionThreadReportOnyxData({
transactionThreadID,
shouldDeleteTransactionThread,
reportAction,
isChatIOUReportArchived,
updatedReportPreviewAction,
shouldAddUpdatedReportPreviewActionToOnyxData = true,
}: {
transactionThreadID?: string;
shouldDeleteTransactionThread: boolean;
reportAction?: ReportAction;
isChatIOUReportArchived?: boolean;
updatedReportPreviewAction?: ReportAction;
shouldAddUpdatedReportPreviewActionToOnyxData?: boolean;
}) {
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];

if (shouldDeleteTransactionThread) {
let transactionThread = null;
let transactionThreadReportActions = null;
if (transactionThreadID) {
transactionThread = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`] ?? null;
transactionThreadReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`] ?? null;
}

optimisticData.push(
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear.
// The remaining parts of the report object will be removed after the API call is successful.
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: {
reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
participants: {
[userAccountID]: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`,
value: null,
},
);
if (transactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: null,
});
}
failureData.push(
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: transactionThread ?? null,
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`,
value: transactionThreadReportActions,
},
);
}

// Update the child comment visible count for reportPreviewAction.
const iouReportID = isMoneyRequestAction(reportAction) ? getOriginalMessage(reportAction)?.IOUReportID : undefined;
const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`];
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReport?.chatReportID}`];
const originalReportPreviewAction = getReportPreviewAction(chatReport?.reportID, iouReport?.reportID) ?? undefined;
let reportPreviewAction = updatedReportPreviewAction ?? originalReportPreviewAction;
if (
originalReportPreviewAction?.reportActionID &&
reportPreviewAction?.reportActionID &&
reportPreviewAction?.childVisibleActionCount &&
reportPreviewAction?.childVisibleActionCount > 0 &&
reportAction?.childVisibleActionCount &&
reportAction?.childVisibleActionCount > 0
) {
let canUserPerformWriteAction = true;
if (chatReport) {
const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport?.reportID}`];
const isArchivedExpenseReport = isArchivedReport(reportNameValuePairs);

canUserPerformWriteAction = !!canUserPerformWriteActionReportUtils(chatReport, isChatIOUReportArchived ?? isArchivedExpenseReport);
}
const lastVisibleAction = getLastVisibleAction(iouReportID, canUserPerformWriteAction);

const {childVisibleActionCount, childCommenterCount, childLastVisibleActionCreated, childOldestFourAccountIDs} = updateOptimisticParentReportAction(
reportPreviewAction,
lastVisibleAction?.childLastVisibleActionCreated ?? lastVisibleAction?.created ?? '',
CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
reportAction.childVisibleActionCount,
);

if (shouldAddUpdatedReportPreviewActionToOnyxData) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction.reportActionID]: {
childVisibleActionCount,
childCommenterCount,
childLastVisibleActionCreated,
childOldestFourAccountIDs,
},
},
});

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction.reportActionID]: {
childVisibleActionCount: originalReportPreviewAction.childVisibleActionCount,
childCommenterCount: originalReportPreviewAction.childCommenterCount,
childLastVisibleActionCreated: originalReportPreviewAction.childLastVisibleActionCreated,
childOldestFourAccountIDs: originalReportPreviewAction.childOldestFourAccountIDs,
},
},
});
}

reportPreviewAction = {...reportPreviewAction, childVisibleActionCount, childCommenterCount, childLastVisibleActionCreated, childOldestFourAccountIDs};
}

return {
optimisticData,
successData,
failureData,
updatedReportPreviewAction: reportPreviewAction,
};
}

/**
*
* @param transactionID - The transactionID of IOU
Expand Down Expand Up @@ -8559,7 +8670,6 @@
updatedIOUReport,
updatedReportPreviewAction,
transactionThreadID,
transactionThread,
transaction,
transactionViolations,
reportPreviewAction,
Expand Down Expand Up @@ -8604,32 +8714,6 @@

removeTransactionFromDuplicateTransactionViolation({optimisticData, failureData}, transactionID, transactions, violations);

if (shouldDeleteTransactionThread) {
optimisticData.push(
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear.
// The remaining parts of the report object will be removed after the API call is successful.
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: {
reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
participants: {
[userAccountID]: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`,
value: null,
},
);
}

optimisticData.push(
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -8699,6 +8783,9 @@
});
}

const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({shouldDeleteTransactionThread, transactionThreadID, reportAction, isChatIOUReportArchived});
optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData);

const successData: OnyxUpdate[] = [
shouldDeleteIOUReport
? {
Expand Down Expand Up @@ -8732,13 +8819,7 @@

// Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response.
// This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function.
if (shouldDeleteTransactionThread && transactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: null,
});
}
successData.push(...cleanUpTransactionThreadReportOnyxData.successData);

if (shouldDeleteIOUReport) {
successData.push({
Expand All @@ -8760,13 +8841,7 @@
value: transactionViolations ?? null,
});

if (shouldDeleteTransactionThread) {
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: transactionThread,
});
}
failureData.push(...cleanUpTransactionThreadReportOnyxData.failureData);

const errorKey = DateUtils.getMicroseconds();

Expand Down Expand Up @@ -13601,6 +13676,7 @@
getPolicyTags,
setMoneyRequestTimeRate,
setMoneyRequestTimeCount,
getCleanUpTransactionThreadReportOnyxData,
handleNavigateAfterExpenseCreate,
buildMinimalTransactionForFormula,
buildOnyxDataForMoneyRequest,
Expand Down
Loading
Loading