Skip to content

Commit d45cd5a

Browse files
authored
Merge pull request #54175 from nkdengineer/fix/53479
Add report action for deleting expenses
2 parents 058dbad + e78accf commit d45cd5a

File tree

8 files changed

+45
-3
lines changed

8 files changed

+45
-3
lines changed

src/CONST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ const CONST = {
10631063
CREATED: 'CREATED',
10641064
DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action
10651065
DELETED_ACCOUNT: 'DELETEDACCOUNT', // Deprecated OldDot Action
1066+
DELETED_TRANSACTION: 'DELETEDTRANSACTION',
10661067
DISMISSED_VIOLATION: 'DISMISSEDVIOLATION',
10671068
DONATION: 'DONATION', // Deprecated OldDot Action
10681069
EXPORTED_TO_CSV: 'EXPORTCSV', // OldDot Action

src/languages/en.ts

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import type {
5959
DelegatorParams,
6060
DeleteActionParams,
6161
DeleteConfirmationParams,
62+
DeleteTransactionParams,
6263
DidSplitAmountMessageParams,
6364
EarlyDiscountSubtitleParams,
6465
EarlyDiscountTitleParams,
@@ -881,6 +882,7 @@ const translations = {
881882
canceled: 'Canceled',
882883
posted: 'Posted',
883884
deleteReceipt: 'Delete receipt',
885+
deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `deleted an expense on this report, ${merchant} - ${amount}`,
884886
pendingMatchWithCreditCard: 'Receipt pending match with card transaction',
885887
pendingMatchWithCreditCardDescription: 'Receipt pending match with card transaction. Mark as cash to cancel.',
886888
markAsCash: 'Mark as cash',

src/languages/es.ts

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import type {
5858
DelegatorParams,
5959
DeleteActionParams,
6060
DeleteConfirmationParams,
61+
DeleteTransactionParams,
6162
DidSplitAmountMessageParams,
6263
EarlyDiscountSubtitleParams,
6364
EarlyDiscountTitleParams,
@@ -880,6 +881,7 @@ const translations = {
880881
pendingMatchWithCreditCardDescription: 'Recibo pendiente de adjuntar con la transacción de la tarjeta. Márcalo como efectivo para cancelar.',
881882
markAsCash: 'Marcar como efectivo',
882883
routePending: 'Ruta pendiente...',
884+
deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `eliminó un gasto de este informe, ${merchant} - ${amount}`,
883885
receiptIssuesFound: () => ({
884886
one: 'Problema encontrado',
885887
other: 'Problemas encontrados',

src/languages/params.ts

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ type RequestCountParams = {
115115
pendingReceipts: number;
116116
};
117117

118+
type DeleteTransactionParams = {
119+
amount: string;
120+
merchant: string;
121+
};
122+
118123
type SettleExpensifyCardParams = {
119124
formattedAmount: string;
120125
};
@@ -725,6 +730,7 @@ export type {
725730
ReportArchiveReasonsRemovedFromPolicyParams,
726731
RequestAmountParams,
727732
RequestCountParams,
733+
DeleteTransactionParams,
728734
RequestedAmountMessageParams,
729735
ResolutionConstraintsParams,
730736
RoomNameReservedErrorParams,

src/libs/ReportUtils.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import {autoSwitchToFocusMode} from './actions/PriorityMode';
6464
import {hasCreditBankAccount} from './actions/ReimbursementAccount/store';
6565
import {handleReportChanged} from './actions/Report';
6666
import {isAnonymousUser as isAnonymousUserSession} from './actions/Session';
67-
import {convertToDisplayString} from './CurrencyUtils';
67+
import {convertToDisplayString, getCurrencySymbol} from './CurrencyUtils';
6868
import DateUtils from './DateUtils';
6969
import {hasValidDraftComment} from './DraftCommentUtils';
7070
import {getMicroSecondOnyxErrorWithTranslationKey} from './ErrorUtils';
@@ -5136,6 +5136,17 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) {
51365136
return Str.htmlEncode(message);
51375137
}
51385138

5139+
function getDeletedTransactionMessage(action: ReportAction) {
5140+
const deletedTransactionOriginalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION>) ?? {};
5141+
const amount = Math.abs(deletedTransactionOriginalMessage.amount ?? 0) / 100;
5142+
const currency = getCurrencySymbol(deletedTransactionOriginalMessage.currency ?? '');
5143+
const message = translateLocal('iou.deletedTransaction', {
5144+
amount: `${currency}${amount}`,
5145+
merchant: deletedTransactionOriginalMessage.merchant ?? '',
5146+
});
5147+
return message;
5148+
}
5149+
51395150
/**
51405151
* @param iouReportID - the report ID of the IOU report the action belongs to
51415152
* @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split)
@@ -8971,6 +8982,7 @@ export {
89718982
getIOUForwardedMessage,
89728983
getRejectedReportMessage,
89738984
getWorkspaceNameUpdatedMessage,
8985+
getDeletedTransactionMessage,
89748986
getUpgradeWorkspaceMessage,
89758987
getDowngradeWorkspaceMessage,
89768988
getReportAutomaticallySubmittedMessage,

src/pages/home/report/ContextMenu/ContextMenuActions.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
canHoldUnholdReportAction,
6565
changeMoneyRequestHoldStatus,
6666
getChildReportNotificationPreference as getChildReportNotificationPreferenceReportUtils,
67+
getDeletedTransactionMessage,
6768
getDowngradeWorkspaceMessage,
6869
getIOUApprovedMessage,
6970
getIOUForwardedMessage,
@@ -545,6 +546,8 @@ const ContextMenuActions: ContextMenuAction[] = [
545546
setClipboardMessage(getPolicyChangeLogChangeRoleMessage(reportAction));
546547
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) {
547548
setClipboardMessage(getPolicyChangeLogDeleteMemberMessage(reportAction));
549+
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) {
550+
setClipboardMessage(getDeletedTransactionMessage(reportAction));
548551
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) {
549552
const {label, errorMessage} = getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''};
550553
setClipboardMessage(translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage}));

src/pages/home/report/PureReportActionItem.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import DisplayNames from '@components/DisplayNames';
1111
import Hoverable from '@components/Hoverable';
1212
import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
1313
import Icon from '@components/Icon';
14-
import * as Expensicons from '@components/Icon/Expensicons';
14+
import {Eye} from '@components/Icon/Expensicons';
1515
import InlineSystemMessage from '@components/InlineSystemMessage';
1616
import KYCWall from '@components/KYCWall';
1717
import OfflineWithFeedback from '@components/OfflineWithFeedback';
@@ -88,6 +88,7 @@ import {
8888
import {
8989
canWriteInReport,
9090
chatIncludesConcierge,
91+
getDeletedTransactionMessage,
9192
getDisplayNamesWithTooltips,
9293
getIconsForParticipants,
9394
getIOUApprovedMessage,
@@ -860,6 +861,8 @@ function PureReportActionItem({
860861
children = <ReportActionItemBasicMessage message={getReportActionText(action)} />;
861862
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
862863
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;
864+
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) {
865+
children = <ReportActionItemBasicMessage message={getDeletedTransactionMessage(action)} />;
863866
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) {
864867
children = <ReportActionItemBasicMessage message={translate('systemMessage.mergedWithCashTransaction')} />;
865868
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) {
@@ -1171,7 +1174,7 @@ function PureReportActionItem({
11711174
<View style={[styles.pl6, styles.mr3]}>
11721175
<Icon
11731176
fill={theme.icon}
1174-
src={Expensicons.Eye}
1177+
src={Eye}
11751178
small
11761179
/>
11771180
</View>

src/types/onyx/OriginalMessage.ts

+13
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ type OriginalMessageModifiedExpense = {
370370
attendees?: string;
371371
};
372372

373+
/** Model of the `deleted transaction` report action */
374+
type OriginalMessageDeletedTransaction = {
375+
/** The merchant of the transaction */
376+
merchant?: string;
377+
378+
/** The amount of the transaction */
379+
amount?: number;
380+
381+
/** The currency of the transaction */
382+
currency?: string;
383+
};
384+
373385
/** Model of `reimbursement queued` report action */
374386
type OriginalMessageReimbursementQueued = {
375387
/** How is the payment getting reimbursed */
@@ -637,6 +649,7 @@ type OriginalMessageMap = {
637649
[CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL]: OriginalMessageCard;
638650
[CONST.REPORT.ACTIONS.TYPE.CARD_ASSIGNED]: OriginalMessageCard;
639651
[CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED]: OriginalMessageIntegrationSyncFailed;
652+
[CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION]: OriginalMessageDeletedTransaction;
640653
} & OldDotOriginalMessageMap & {
641654
[T in ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG>]: OriginalMessageChangeLog;
642655
} & {

0 commit comments

Comments
 (0)