Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,14 @@ function getIOUActionForReportID(reportID: string, transactionID: string): OnyxE
return action;
}

/**
* Get the track expense actionable whisper of the corresponding track expense
*/
function getTrackExpenseActionableWhisper(transactionID: string, chatReportID: string) {
const chatReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`] ?? {};
return Object.values(chatReportActions).find((action: ReportAction) => isActionableTrackExpense(action) && getOriginalMessage(action)?.transactionID === transactionID);
}

export {
extractLinksFromMessageHtml,
getDismissedViolationMessageText,
Expand Down Expand Up @@ -1418,6 +1426,7 @@ export {
isMemberChangeAction,
getMemberChangeMessageFragment,
isOldDotReportAction,
getTrackExpenseActionableWhisper,
getMessageOfOldDotReportAction,
getMemberChangeMessagePlainText,
isReimbursementDeQueuedAction,
Expand Down
17 changes: 15 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1707,13 +1707,16 @@ function getDeleteTrackExpenseInformation(
}

if (actionableWhisperReportActionID) {
const actionableWhisperReportAction = ReportActionsUtils.getReportAction(chatReportID, actionableWhisperReportActionID);
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[actionableWhisperReportActionID]: {
originalMessage: {
resolution: null,
resolution: ReportActionsUtils.isActionableTrackExpense(actionableWhisperReportAction)
? ReportActionsUtils.getOriginalMessage(actionableWhisperReportAction)?.resolution ?? null
: null,
},
},
},
Expand Down Expand Up @@ -5586,7 +5589,17 @@ function deleteTrackExpense(chatReportID: string, transactionID: string, reportA
return deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView);
}

const {parameters, optimisticData, successData, failureData, shouldDeleteTransactionThread} = getDeleteTrackExpenseInformation(chatReportID, transactionID, reportAction);
const whisperAction = ReportActionsUtils.getTrackExpenseActionableWhisper(transactionID, chatReportID);
const actionableWhisperReportActionID = whisperAction?.reportActionID;
const {parameters, optimisticData, successData, failureData, shouldDeleteTransactionThread} = getDeleteTrackExpenseInformation(
chatReportID,
transactionID,
reportAction,
undefined,
undefined,
actionableWhisperReportActionID,
Comment thread
truph01 marked this conversation as resolved.
CONST.REPORT.ACTIONABLE_TRACK_EXPENSE_WHISPER_RESOLUTION.NOTHING,
);

// STEP 6: Make the API request
API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData});
Expand Down