Skip to content

Add delete report option - #70349

Merged
techievivek merged 17 commits into
Expensify:mainfrom
bernhardoj:fix/69546-add-option-to-delete-report
Sep 25, 2025
Merged

techievivek merged 17 commits into
Expensify:mainfrom
bernhardoj:fix/69546-add-option-to-delete-report

Conversation

@bernhardoj

@bernhardoj bernhardoj commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #69546
PROPOSAL: #69546 (comment)

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

Same as QA Steps

QA Steps

  1. Open a workspace chat
  2. Create an empty report
  3. Create a new report with at least 2 expenses
  4. Right click on each report preview
  5. Verify there is a delete option
  6. Delete the report preview
  7. Verify the report preview is deleted

NOTE for QA:
If the report preview only has 1 expense and has never been opened before, the confirmation modal will say delete report instead of delete expense. It's technically an existing issue.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4

@bernhardoj
bernhardoj requested a review from a team as a code owner September 11, 2025 04:48
@melvin-bot
melvin-bot Bot requested review from dominictb and removed request for a team September 11, 2025 04:48
@melvin-bot

melvin-bot Bot commented Sep 11, 2025

Copy link
Copy Markdown

@dominictb Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@bernhardoj

Copy link
Copy Markdown
Contributor Author

I'm still having trouble running the iOS app.

@dominictb

Copy link
Copy Markdown
Contributor

@bernhardoj Can you merge main on this and add iOS recording?

@bernhardoj

Copy link
Copy Markdown
Contributor Author

Oh, I forgot to add the iOS recording when my iOS was already working. Now I can't run it anymore.

@dominictb

Copy link
Copy Markdown
Contributor

@bernhardoj Please check other language files and resolve failed check.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

Done.

iOS is still failing.

image

@dominictb

dominictb commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

@bernhardoj I haven't seen translated copies for other languages. For now as the generateTranslations script does not work, can you manually translate and update other languages correspondingly (de.ts, fr.ts,...)?

@dominictb

Copy link
Copy Markdown
Contributor

Hi @Expensify/product-pr @Expensify/design we're trying to add the Delete report option to the context menu:

Screenshot 2025-09-17 at 19 23 02 Screenshot 2025-09-17 at 19 24 44

We want your confirmation on the option copy. Here's how it currently works:

  • If the expense report has no expense, or multiple expenses (0 or > 1 expenses), show Delete report, and the confirmation modal says Are you sure want to delete this report?
  • If the expense report has a single expense, show Delete expense, and the confirmation modal says Are you sure want to delete this expense?

Does that sound good?

@trjExpensify

Copy link
Copy Markdown
Contributor

Wouldn't we follow exactly what we do for the delete option in the More menu here?

  • Menu item is Delete
  • Confirmation modal and copy is either the "Delete expense" or "Delete report" variation depending on if it's a expense/one-expense report or multi-expense report.

@shawnborton

Copy link
Copy Markdown
Contributor

Totally agree with Tom here, let's reuse the exact same pattern that already exists.

@dominictb

dominictb commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

Menu item is Delete

Currently we're showing Delete comment and Delete expense on prod in context menu:

Screenshot 2025-09-17 at 20 04 16 Screenshot 2025-09-17 at 20 04 26

So if want to make it Delete only, we would have Delete comment for comments and Delete for expense-related.

@trjExpensify

Copy link
Copy Markdown
Contributor

So if want to make it Delete only, we would have Delete comment for comments and Delete for expense-related.

Mhm, there's never a time where Delete [comment||expense||report] would show in the menu at the same time, right? So I think the button being Delete for brevity is fine personally. Thereafter, the confirmation dialogue is tailored to the object you're deleting.. be that a comment, expense, or report.

@dominictb

Copy link
Copy Markdown
Contributor

Agree. @bernhardoj Let's make it only Delete across the board.

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Not sure where we added Delete [object] though I want to confirm that was explicitly not the original design. So I agree with @trjExpensify should remove it and stick with Delete everywhere.

@bernhardoj
bernhardoj requested a review from a team as a code owner September 18, 2025 03:17
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@bernhardoj

bernhardoj commented Sep 18, 2025 •

Copy link
Copy Markdown
Contributor Author

For now as the generateTranslations script does not work,

I think we can ask the team to run the script since it requires OpenAI API key.

@dominictb

dominictb commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

@bernhardoj Can you update steps 5-7 in your tests to reflect the latest changes regarding the Delete option name and the confirmation messages for expense and report? Also add a note that if the the report is not yet open, it's always Delete report as per #70349 (comment), this seems like a BE bug/an existing bug on main.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

Done

@dominictb dominictb left a comment

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.

Except for this bug #70349 (comment) that has already happened on prod, which is caused by missing the expense report actions data (it's only available once we open it), everything looks good and tests well.

🎀👀🎀

@melvin-bot
melvin-bot Bot requested a review from techievivek September 22, 2025 15:37
@techievivek

Copy link
Copy Markdown
Contributor

@dominictb Have you reported the above bug? Also @bernhardoj there are conflicts, can you fix them, thanks.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

Fixed

@dominictb

Copy link
Copy Markdown
Contributor

@techievivek I've just reported this bug here.

@techievivek techievivek left a comment

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.

Looks good, just have a quick question regarding selfDM behaviour.

Comment thread src/libs/ReportUtils.ts Outdated
return true;
}

if (isSelfDM(report)) {

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 don't think we allow users to delete selfDM, no? Did we check on this?

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.

Oh this means that you can delete your own tracked expenses in self DM. All the logic in this function was moved intact from this one:

if (isUnreported) {
return isOwner;
}

@techievivek techievivek Sep 23, 2025 •

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.

That is for the action, no? @bernhardoj's change is for the report, right?

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 it's fine to delete unreported transactions that may sit inside selfDM but not the selfDM report itself.

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.

Ok, I see the usage, and it sort of does the same thing but the function name confused me.

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.

The canDeleteReport name? I named it like this because we are technically deleting the report and also we use this to show the delete option in the expense report itself.

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.

Hmm, but we can't delete the selfDM, no? So why does that method return true for selfDM?

@dominictb dominictb Sep 24, 2025 •

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 does not mean "deleting the self DM report", it's returning isOwner which means if this transaction is in the self DM and you owned it (technically your tracked expense), you can delete it. So it means you can delete your own tracked expenses.

@bernhardoj I think the function name could be canDeleteMoneyRequestReport. And you can keep the old name isUnreported = isSelfDM so it's not misunderstood as deleting the self DM itself.

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 does not mean "deleting the self DM report", it's returning isOwner which means if this transaction is in the self DM and you owned it (technically your tracked expense), you can delete it. So it means you can delete your own tracked expenses.

Yeah, I understood the same but the method name confused me, I think your suggestion works for me.

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.

Updated

@melvin-bot
melvin-bot Bot requested a review from techievivek September 24, 2025 16:28
@techievivek

Copy link
Copy Markdown
Contributor

@bernhardoj Can you please fix the conflicts, we can then get this merged.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

@techievivek fixed

@codecov

codecov Bot commented Sep 25, 2025

Copy link
Copy Markdown

@techievivek
techievivek merged commit 9fef0d3 into Expensify:main Sep 25, 2025
20 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Sep 26, 2025
62 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/techievivek in version: 9.2.19-0 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.2.19-3 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Comment thread src/libs/ReportUtils.ts
const isApprovalEnabled = policy ? policy.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL : false;
const isForwarded = isProcessingReport(report) && isApprovalEnabled && !isAwaitingFirstLevelApproval(report);

return isReportSubmitter && isReportOpenOrProcessing && !isForwarded;

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'm not sure if it comes from this PR or it's the new requirement
But after bypassing approver, the Delete option should be present in More menu because the report is not approved yet.
More context here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants