Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Hide whisper action when deleting track expense in offline #43977

Merged
merged 7 commits into from
Jun 28, 2024
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,
truph01 marked this conversation as resolved.
Show resolved Hide 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
Loading