Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.34k stars 2.77k forks source link

[$250] Workspace - Able to delete expense from archived workspace #48588

Open IuliiaHerets opened 2 weeks ago

IuliiaHerets commented 2 weeks ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.29-5 Reproducible in staging?: Y Reproducible in production?: Y Issue reported by: Applause Internal Team

Action Performed:

  1. Launch app
  2. Create a WS
  3. Submit one or few expenses
  4. Delete the workspace
  5. Open archived WS chat
  6. Tap header -- delete expense

Expected Result:

User must not be able to delete expense from archived workspace.

Actual Result:

Able to delete expense from archived workspace.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/a5ba6eb5-e126-4ac8-b157-83b1ea8f0549

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021833087706130184523
  • Upwork Job ID: 1833087706130184523
  • Last Price Increase: 2024-09-09
  • Automatic offers:
    • situchan | Reviewer | 103922957
    • FitseTLT | Contributor | 103922958
Issue OwnerCurrent Issue Owner: @FitseTLT
melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @zanyrenney (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

IuliiaHerets commented 2 weeks ago

@zanyrenney z FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

FitseTLT commented 2 weeks ago

Edited by proposal-police: This proposal was edited at 2024-09-04 19:02:31 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Workspace - Able to delete expense from archived workspace

What is the root cause of that problem?

We don't check if it is archived in can add or delete transaction here https://github.com/Expensify/App/blob/6760f96d9f7fc425e6972be27e5fb0a277805bd6/src/libs/ReportUtils.ts#L1653-L1657

What changes do you think we should make in order to solve the problem?

We should return false if the report is archived one

if (!isMoneyRequestReport(moneyRequestReport)|| isArchivedRoom(moneyRequestReport)) {
        return false;

If we don't want to apply it to add transaction too we can apply the check (is not archived check) only for canDeleteTransaction here In addition to preventing the deletion in FE we need to also ensure the BE doesn't allow deletion for archived workspace

Note: we don't need to apply the check for shouldShowTaskDeleteButton because we already have it here https://github.com/Expensify/App/blob/6760f96d9f7fc425e6972be27e5fb0a277805bd6/src/pages/ReportDetailsPage.tsx#L198

What alternative solutions did you explore? (Optional)

eucool commented 2 weeks ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

We see delete report action even when the workspace is archived

What is the root cause of that problem?



The actual bug here is that we see the delete action even when the workspace is archived this is because we do not hide the button when the workspace is archived: 

 https://github.com/Expensify/App/blob/f040cf22a81475354eb352cf808c8ba9acc0de4f/src/pages/ReportDetailsPage.tsx#L201

What changes do you think we should make in order to solve the problem?

Update the condition to:

const shouldShowDeleteButton = (shouldShowTaskDeleteButton || canDeleteRequest ) && !isArchivedRoom;

Or update the shouldShowTaskDeleteButton directly to hide the button by adding the isArchivedRoom check there

What alternative solutions did you explore? (Optional)

zanyrenney commented 1 week ago

Ooh sorry I totally missed this one!

zanyrenney commented 1 week ago

Reviewing now.

zanyrenney commented 1 week ago

Adding External

melvin-bot[bot] commented 1 week ago

Job added to Upwork: https://www.upwork.com/jobs/~021833087706130184523

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (External)

zanyrenney commented 1 week ago

hey @situchan please review the proposals above and let me know which one is best so we can move ahead here. Thank you!

situchan commented 1 week ago

@FitseTLT's proposal looks good to me. 🎀👀🎀 C+ reviewed

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @aldo-expensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] commented 1 week ago

📣 @situchan 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 week ago

📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

zanyrenney commented 6 days ago

hello! how are we getting along here @FitseTLT @situchan thanks!

zanyrenney commented 6 days ago

cc @aldo-expensify

FitseTLT commented 6 days ago

PR ready