Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
82f636e
create v1 for DeleteAppReport
allgandalf Mar 7, 2025
04737c3
Merge branch 'main' into DeleteAppReport
allgandalf Mar 21, 2025
a67f18f
build delete report action
allgandalf Mar 22, 2025
1615ce2
Merge branch 'main' into DeleteAppReport
allgandalf Apr 14, 2025
f161477
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf Apr 15, 2025
6333b12
test: send serialized object
allgandalf Apr 15, 2025
8a59591
Merge branch 'main' into DeleteAppReport
allgandalf Apr 22, 2025
29e383b
generate new report actions
allgandalf Apr 22, 2025
6cca61c
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf Apr 24, 2025
9cbf409
try to make CI green
allgandalf May 2, 2025
5b721c2
Merge branch 'main' into DeleteAppReport
allgandalf May 2, 2025
5d12b7f
make CI green
allgandalf May 2, 2025
19d72ad
Merge branch 'DeleteAppReport' of https://github.com/allgandalf/App i…
allgandalf May 2, 2025
ac728eb
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 3, 2025
f1ce165
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 7, 2025
35e06c5
address few comments
allgandalf May 7, 2025
bc904c7
fix: condition to show delete report
allgandalf May 7, 2025
8106089
Fix prettier
allgandalf May 7, 2025
527ba70
fix navigating back to selfDM
allgandalf May 7, 2025
1ec0bfc
fix prettier
allgandalf May 7, 2025
ae72bf6
polish: Add pending action
allgandalf May 7, 2025
9f416a2
Update src/pages/ReportDetailsPage.tsx
allgandalf May 7, 2025
8b07977
fix failing tests
allgandalf May 7, 2025
9fbc154
Merge branch 'DeleteAppReport' of https://github.com/allgandalf/App i…
allgandalf May 7, 2025
78e96c3
fix failing tests
allgandalf May 7, 2025
bf65471
Fix prettier
allgandalf May 7, 2025
be88e98
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 7, 2025
a53e566
Merge branch 'main' into DeleteAppReport
allgandalf May 20, 2025
6121e5c
update the unreportedTransaction message
allgandalf May 20, 2025
c38491a
use unreportedTransaction message in pureReportActions
allgandalf May 20, 2025
c36e1c0
remove use of OriginalMessageUnreportedTransaction
allgandalf May 20, 2025
9f261e2
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 20, 2025
557caa0
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 20, 2025
324b779
add selfDMCreatedReportActionID
allgandalf May 20, 2025
602d991
Merge branch 'Expensify:main' into DeleteAppReport
allgandalf May 20, 2025
f388b13
remove unwanted .md file
allgandalf May 20, 2025
ba2b8e5
add failure data
allgandalf May 20, 2025
e9ef5c5
fix failure data and update condition for isDeleteAction
allgandalf May 20, 2025
a90bd0d
Merge branch 'main' into DeleteAppReport
allgandalf May 21, 2025
df01e66
address dylans comments
allgandalf May 21, 2025
7f22c66
introduce transactionIDToReportActionAndThreadData
allgandalf May 21, 2025
7420bb6
revert report delete changes in report details page
allgandalf May 21, 2025
19b6020
Add delete reprot functionality to report
allgandalf May 21, 2025
bd8d7ce
address reviewers comment
allgandalf May 22, 2025
b9831de
Apply suggestions from code review
allgandalf May 22, 2025
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
33 changes: 27 additions & 6 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useSelectedTransactionsActions from '@hooks/useSelectedTransactionsAction
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {downloadReportPDF, exportReportToCSV, exportReportToPDF, exportToIntegration, markAsManuallyExported, openUnreportedExpense} from '@libs/actions/Report';
import {deleteAppReport, downloadReportPDF, exportReportToCSV, exportReportToPDF, exportToIntegration, markAsManuallyExported, openUnreportedExpense} from '@libs/actions/Report';
import {getThreadReportIDsForTransactions, getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportUtils';
import Navigation from '@libs/Navigation/Navigation';
import {buildOptimisticNextStepForPreventSelfApprovalsEnabled} from '@libs/NextStepUtils';
Expand Down Expand Up @@ -165,7 +165,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea

const [downloadErrorModalVisible, setDownloadErrorModalVisible] = useState(false);
const [isCancelPaymentModalVisible, setIsCancelPaymentModalVisible] = useState(false);
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
const [isDeleteExpenseModalVisible, setIsDeleteExpenseModalVisible] = useState(false);
const [isDeleteReportModalVisible, setIsDeleteReportModalVisible] = useState(false);
const [isUnapproveModalVisible, setIsUnapproveModalVisible] = useState(false);
const [isReopenWarningModalVisible, setIsReopenWarningModalVisible] = useState(false);
const [isPDFModalVisible, setIsPDFModalVisible] = useState(false);
Expand Down Expand Up @@ -736,7 +737,11 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
icon: Expensicons.Trashcan,
value: CONST.REPORT.SECONDARY_ACTIONS.DELETE,
onSelected: () => {
setIsDeleteModalVisible(true);
if (Object.keys(transactions).length === 1) {
setIsDeleteExpenseModalVisible(true);
} else {
setIsDeleteReportModalVisible(true);
}
},
},
[CONST.REPORT.SECONDARY_ACTIONS.REOPEN]: {
Expand Down Expand Up @@ -945,9 +950,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
/>
<ConfirmModal
title={translate('iou.deleteExpense', {count: 1})}
isVisible={isDeleteModalVisible}
isVisible={isDeleteExpenseModalVisible}
onConfirm={() => {
setIsDeleteModalVisible(false);
setIsDeleteExpenseModalVisible(false);
let goBackRoute: Route | undefined;
if (transactionThreadReportID) {
if (!requestParentReportAction || !transaction?.transactionID) {
Expand All @@ -962,7 +967,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
Navigation.navigate(goBackRoute);
}
}}
onCancel={() => setIsDeleteModalVisible(false)}
onCancel={() => setIsDeleteExpenseModalVisible(false)}
prompt={translate('iou.deleteConfirmation', {count: 1})}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
Expand All @@ -980,6 +985,22 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
danger
shouldEnableNewFocusManagement
/>
<ConfirmModal
title={translate('iou.deleteReport')}
isVisible={isDeleteReportModalVisible}
onConfirm={() => {
setIsDeleteReportModalVisible(false);

deleteAppReport(moneyRequestReport?.reportID);

@rushatgabhane rushatgabhane Jul 3, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line caused a bug - #63094 (comment)

we should have waiting for deleteAppReport to complete before navigating

Navigation.goBack();
}}
onCancel={() => setIsDeleteReportModalVisible(false)}
prompt={translate('iou.deleteReportConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
danger
shouldEnableNewFocusManagement
/>
{!!connectedIntegration && (
<ConfirmModal
title={translate('workspace.exportAgainModal.title')}
Expand Down
5 changes: 3 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ import type {
TransferParams,
TrialStartedTitleParams,
UnapproveWithIntegrationWarningParams,
UnreportedTransactionParams,
UnshareParams,
UntilTimeParams,
UpdatedCustomFieldParams,
Expand Down Expand Up @@ -952,7 +951,7 @@ const translations = {
deleteReceipt: 'Delete receipt',
deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `deleted an expense on this report, ${merchant} - ${amount}`,
movedTransaction: ({reportUrl, reportName}: MovedTransactionParams) => `moved this expense to <a href="${reportUrl}">${reportName}</a>`,
unreportedTransaction: ({reportUrl, reportName}: UnreportedTransactionParams) => `removed this expense from <a href="${reportUrl}">${reportName}</a>`,
unreportedTransaction: 'moved this expense to your personal space',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing a hyperlink so we updated it in #68586

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey i think we didn't want a hyperlink at the time of the PR, so i don't this this PR would be the offending one, please update the C+ checklist accordingly 😄 c.c. @luacmartins

pendingMatchWithCreditCard: 'Receipt pending match with card transaction',
pendingMatch: 'Pending match',
pendingMatchWithCreditCardDescription: 'Receipt pending match with card transaction. Mark as cash to cancel.',
Expand Down Expand Up @@ -1016,6 +1015,8 @@ const translations = {
one: 'Are you sure that you want to delete this expense?',
other: 'Are you sure that you want to delete these expenses?',
}),
deleteReport: 'Delete report',
deleteReportConfirmation: 'Are you sure that you want to delete this report?',
settledExpensify: 'Paid',
done: 'Done',
settledElsewhere: 'Paid elsewhere',
Expand Down
5 changes: 3 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ import type {
TransferParams,
TrialStartedTitleParams,
UnapproveWithIntegrationWarningParams,
UnreportedTransactionParams,
UnshareParams,
UntilTimeParams,
UpdatedCustomFieldParams,
Expand Down Expand Up @@ -952,7 +951,7 @@ const translations = {
routePending: 'Ruta pendiente...',
deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `eliminó un gasto de este informe, ${merchant} - ${amount}`,
movedTransaction: ({reportUrl, reportName}: MovedTransactionParams) => `movió este gasto a <a href="${reportUrl}">${reportName}</a>`,
unreportedTransaction: ({reportUrl, reportName}: UnreportedTransactionParams) => `eliminó este gasto de <a href="${reportUrl}">${reportName}</a>`,
unreportedTransaction: 'movió este gasto a tu espacio personal',
receiptIssuesFound: () => ({
one: 'Problema encontrado',
other: 'Problemas encontrados',
Expand Down Expand Up @@ -1011,6 +1010,8 @@ const translations = {
one: '¿Estás seguro de que quieres eliminar esta solicitud?',
other: '¿Estás seguro de que quieres eliminar estas solicitudes?',
}),
deleteReport: 'Eliminar informe',
deleteReportConfirmation: '¿Estás seguro de que quieres eliminar este informe?',
settledExpensify: 'Pagado',
done: 'Listo',
settledElsewhere: 'Pagado de otra forma',
Expand Down
6 changes: 0 additions & 6 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ type MovedTransactionParams = {
reportName?: string;
};

type UnreportedTransactionParams = {
reportUrl: string;
reportName?: string;
};

type SettleExpensifyCardParams = {
formattedAmount: string;
};
Expand Down Expand Up @@ -825,7 +820,6 @@ export type {
RequestCountParams,
DeleteTransactionParams,
MovedTransactionParams,
UnreportedTransactionParams,
RequestedAmountMessageParams,
ResolutionConstraintsParams,
RoomNameReservedErrorParams,
Expand Down
8 changes: 8 additions & 0 deletions src/libs/API/parameters/DeleteAppReportParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type DeleteAppReportParams = {
reportID: string;
transactionIDToReportActionAndThreadData?: string;
selfDMReportID?: string;
selfDMCreatedReportActionID?: string;
};

export default DeleteAppReportParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export type {default as GetCorpayOnboardingFieldsParams} from './GetCorpayOnboar
export type {SaveCorpayOnboardingCompanyDetailsParams} from './SaveCorpayOnboardingCompanyDetailsParams';
export type {default as AcceptSpotnanaTermsParams} from './AcceptSpotnanaTermsParams';
export type {default as SaveCorpayOnboardingBeneficialOwnerParams} from './SaveCorpayOnboardingBeneficialOwnerParams';
export type {default as DeleteAppReportParams} from './DeleteAppReportParams';
export type {default as SaveCorpayOnboardingDirectorInformationParams} from './SaveCorpayOnboardingDirectorInformationParams';
export type {default as MoveIOUReportToPolicyAndInviteSubmitterParams} from './MoveIOUReportToPolicyAndInviteSubmitterParams';
export type {default as MoveIOUReportToExistingPolicyParams} from './MoveIOUReportToExistingPolicyParams';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ const WRITE_COMMANDS = {
RESET_SMS_DELIVERY_FAILURE_STATUS: 'ResetSMSDeliveryFailureStatus',
SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS: 'SaveCorpayOnboardingCompanyDetails',
SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER: 'SaveCorpayOnboardingBeneficialOwner',
DELETE_APP_REPORT: 'DeleteAppReport',
ADD_WORK_EMAIL: 'AddWorkEmail',
SAVE_CORPAY_ONBOARDING_DIRECTOR_INFORMATION: 'SaveCorpayOnboardingDirectorInformation',
CHANGE_REPORT_POLICY: 'ChangeReportPolicy',
Expand Down Expand Up @@ -966,6 +967,7 @@ type WriteCommandParameters = {

// Dismiss Product Training
[WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING]: Parameters.DismissProductTrainingParams;
[WRITE_COMMANDS.DELETE_APP_REPORT]: Parameters.DeleteAppReportParams;
[WRITE_COMMANDS.ADD_WORK_EMAIL]: Parameters.AddWorkEmailParams;

// Merge accounts API
Expand Down
14 changes: 5 additions & 9 deletions src/libs/ReportSecondaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,11 @@ function isMoveTransactionAction(reportTransactions: Transaction[], reportAction
return canMoveExpense;
}

function isDeleteAction(report: Report, reportTransactions: Transaction[], reportActions?: ReportAction[]): boolean {
const transactionThreadReportID = getOneTransactionThreadReportID(report.reportID, reportActions ?? []);
function isDeleteAction(report: Report): boolean {
Comment thread
allgandalf marked this conversation as resolved.
const isExpenseReport = isExpenseReportUtils(report);
const isIOUReport = isIOUReportUtils(report);

// This should be removed when is merged https://github.com/Expensify/App/pull/58020
const isSingleTransaction = reportTransactions.length === 1;

if ((!isExpenseReport && !isIOUReport) || !isSingleTransaction || (!!reportActions && !transactionThreadReportID)) {
if (!isExpenseReport && !isIOUReport) {
return false;
}

Expand Down Expand Up @@ -448,7 +444,7 @@ function getSecondaryReportActions(

options.push(CONST.REPORT.SECONDARY_ACTIONS.VIEW_DETAILS);

if (isDeleteAction(report, reportTransactions, reportActions)) {
if (isDeleteAction(report)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.DELETE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should update the CONST.REPORT.SECONDARY_ACTIONS.DELETE const to deleteReport so we can differentiate it from CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DELETE and setup the proper action in secondaryActionsImplementation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allgandalf we're also missing the action setup here (the current one is for the delete expense case) so we need to add one for the delete report case. And the correct modal/callback here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this Now

}

Expand All @@ -464,10 +460,10 @@ function getSecondaryTransactionThreadActions(parentReport: Report, reportTransa

options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.VIEW_DETAILS);

if (isDeleteAction(parentReport, [reportTransaction])) {
if (isDeleteAction(parentReport)) {
options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DELETE);
}

return options;
}
export {getSecondaryReportActions, getSecondaryTransactionThreadActions};
export {getSecondaryReportActions, getSecondaryTransactionThreadActions, isDeleteAction};
26 changes: 7 additions & 19 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
OriginalMessageIOU,
OriginalMessageModifiedExpense,
OriginalMessageMovedTransaction,
OriginalMessageUnreportedTransaction,
} from 'src/types/onyx/OriginalMessage';
import type {SetRequired, TupleToUnion, ValueOf} from 'type-fest';
import type {FileObject} from '@components/AttachmentModal';
Expand Down Expand Up @@ -813,6 +812,11 @@ type GetChatRoomSubtitleConfig = {
isCreateExpenseFlow?: boolean;
};

type SelfDMParameters = {
reportID?: string;
createdReportActionID?: string;
};

type GetPolicyNameParams = {
report: OnyxInputOrEntry<Report>;
returnEmptyIfNotFound?: boolean;
Expand Down Expand Up @@ -5798,17 +5802,6 @@ function getMovedTransactionMessage(action: ReportAction) {
return message;
}

function getUnreportedTransactionMessage(action: ReportAction) {
const unreportedTransactionOriginalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION>) ?? {};
const {fromReportID} = unreportedTransactionOriginalMessage as OriginalMessageUnreportedTransaction;
const {reportName, reportUrl} = getReportDetails(fromReportID);
const message = translateLocal('iou.unreportedTransaction', {
reportUrl,
reportName,
});
return message;
}

function getPolicyChangeMessage(action: ReportAction) {
const PolicyChangeOriginalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY>) ?? {};
const {fromPolicy: fromPolicyID, toPolicy: toPolicyID} = PolicyChangeOriginalMessage as OriginalMessageChangePolicy;
Expand Down Expand Up @@ -6182,7 +6175,7 @@ function buildOptimisticTransactionAction(
const [actionText, messageHtml] =
type === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION
? [`moved this expense to ${reportName}`, `moved this expense to <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`]
: [`removed this expense from ${reportName}`, `removed this expense from <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`];
: ['moved this expense to your personal space', 'moved this expense to your personal space'];

return {
actionName: type,
Expand Down Expand Up @@ -10153,11 +10146,6 @@ function prepareOnboardingOnyxData(
guidedSetupData.push({type: 'message', ...textMessage});
}

type SelfDMParameters = {
reportID?: string;
createdReportActionID?: string;
};

let selfDMParameters: SelfDMParameters = {};
if (engagementChoice === CONST.ONBOARDING_CHOICES.PERSONAL_SPEND) {
const selfDMReportID = findSelfDMReportID();
Expand Down Expand Up @@ -11114,7 +11102,6 @@ export {
getReportSubtitlePrefix,
getPolicyChangeMessage,
getMovedTransactionMessage,
getUnreportedTransactionMessage,
getExpenseReportStateAndStatus,
generateReportName,
navigateToLinkedReportAction,
Expand Down Expand Up @@ -11151,4 +11138,5 @@ export type {
ParsingDetails,
MissingPaymentMethod,
OptimisticNewReport,
SelfDMParameters,
};
Loading