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

[$250] Search - Hold and Delete option are available for expense in the deleted (archived) workspace #50352

Open
6 tasks done
lanitochka17 opened this issue Oct 7, 2024 · 24 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 7, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.39-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit an expense
  4. Delete the workspace
  5. Go to Search
  6. Select the expense in Step 3 via checkbox
  7. Click on the dropdown

Expected Result:

Hold and Delete option should not be available for expense in the deleted (archived) workspace

Actual Result:

Hold and Delete option are available for expense in the deleted (archived) workspace

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6609901_1726834959751.20240920_201913.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021843452809268772596
  • Upwork Job ID: 1843452809268772596
  • Last Price Increase: 2024-10-08
  • Automatic offers:
    • Nodebrute | Contributor | 104460258
Issue OwnerCurrent Issue Owner: @mallenexpensify
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 7, 2024
Copy link

melvin-bot bot commented Oct 7, 2024

Triggered auto assignment to @mallenexpensify (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.

@lanitochka17
Copy link
Author

@mallenexpensify 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

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-control

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 7, 2024

Edited by proposal-police: This proposal was edited at 2024-10-07 19:47:40 UTC.

Proposal

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

Hold and Delete option are available for expense in the deleted (archived) workspace

What is the root cause of that problem?

Here we set canHold to item.canHold but when we delete workspace item.canHold will still be true

return {...selectedTransactions, [item.keyForList]: {isSelected: true, canDelete: item.canDelete, canHold: item.canHold, canUnhold: item.canUnhold, action: item.action}};

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

We need to add new checks here for cases like where if workspace is deleted we don't show hold button. We can do something like this here

   const isArchivedReport = ReportUtils.isArchivedRoomWithID(item.reportID)
    const canHoldtransaction = !isArchivedReport && item.canHold

and then we can use this here canHold: canHoldtransaction

If we also want to hide delete button we can do the same for canDelete. We should also look for other cases where we don't want to hold and delete button and fix that here too.

What alternative solutions did you explore? (Optional)

Alternatively, we can add !isArchivedReport here

const shouldShowHoldOption = !isOffline && selectedTransactionsKeys.every((id) => selectedTransactions[id].canHold);

And if we want to hide the delete button we can do the same for delete button

@ChavdaSachin
Copy link
Contributor

Proposal

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

Hold and Delete option are available for expense in the deleted (archived) workspace

What is the root cause of that problem?

  • When we delete workspace here we only set archive rules for workspace reports, and workspace transactions retains the last state it had when workspace was archived. Hence when we fetch transactions from ONYX - the transaction properties are outdated.

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

  • To solve this issue we should set transaction properties canHold and canDelete to false for every transaction in workspace to be deleted.
  • So similar to how we archive reports when we delete workspace, we need to set canHold and canDelete properties for all workspace transactions to false and pass it to API data here.
    function deleteWorkspace(policyID: string, policyName: string) {
    if (!allPolicies) {
    return;
    }
    const filteredPolicies = Object.values(allPolicies).filter((policy): policy is Policy => policy?.id !== policyID);
    const optimisticData: OnyxUpdate[] = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
    value: {
    avatarURL: '',
    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
    errors: null,
    },
    },
    ...(!hasActiveChatEnabledPolicies(filteredPolicies, true)
    ? [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
    value: {
    errors: null,
    },
    },
    ]
    : []),
    ];
    const reportsToArchive = Object.values(ReportConnection.getAllReports() ?? {}).filter(
    (report) => report?.policyID === policyID && (ReportUtils.isChatRoom(report) || ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isTaskReport(report)),
    );
    const finallyData: OnyxUpdate[] = [];
    const currentTime = DateUtils.getDBTime();
    reportsToArchive.forEach((report) => {
    const {reportID, ownerAccountID} = report ?? {};
    optimisticData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: {
    stateNum: CONST.REPORT.STATE_NUM.APPROVED,
    statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
    oldPolicyName: allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? '',
    policyName: '',
    // eslint-disable-next-line @typescript-eslint/naming-convention
    private_isArchived: currentTime,
    },
    });
    optimisticData.push({
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${reportID}`,
    value: null,
    });
    // Add closed actions to all chat reports linked to this policy
    // Announce & admin chats have FAKE owners, but workspace chats w/ users do have owners.
    let emailClosingReport: string = CONST.POLICY.OWNER_EMAIL_FAKE;
    if (!!ownerAccountID && ownerAccountID !== CONST.POLICY.OWNER_ACCOUNT_ID_FAKE) {
    emailClosingReport = allPersonalDetails?.[ownerAccountID]?.login ?? '';
    }
    const optimisticClosedReportAction = ReportUtils.buildOptimisticClosedReportAction(emailClosingReport, policyName, CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED);
    optimisticData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
    value: {
    [optimisticClosedReportAction.reportActionID]: optimisticClosedReportAction as ReportAction,
    },
    });
    // We are temporarily adding this workaround because 'DeleteWorkspace' doesn't
    // support receiving the optimistic reportActions' ids for the moment.
    finallyData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
    value: {
    [optimisticClosedReportAction.reportActionID]: null,
    },
    });
    });

We might need BE support here as well.
This will avoid current and future problems it could cause.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

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

@melvin-bot melvin-bot bot changed the title Search - Hold and Delete option are available for expense in the deleted (archived) workspace [$250] Search - Hold and Delete option are available for expense in the deleted (archived) workspace Oct 8, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

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

@mallenexpensify mallenexpensify removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 8, 2024
@mallenexpensify
Copy link
Contributor

@fedirjh are you able to reproduce? I wasn't (but I did a couple additional steps to add another workspace cuz I couldn't delete mine without another)
image

image

@fedirjh
Copy link
Contributor

fedirjh commented Oct 9, 2024

@mallenexpensify I was able to reproduce. The bug appears on the search page, not the expense page :

Screenshot 2024-10-09 at 11 20 25 AM

@mallenexpensify mallenexpensify added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 9, 2024
@mallenexpensify
Copy link
Contributor

Thanks @fedirjh , added Help Wanted, can you review the proposals above? Thx

Copy link

melvin-bot bot commented Oct 14, 2024

@mallenexpensify, @fedirjh Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Oct 14, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Oct 14, 2024

Thanks to @Nodebrute and @ChavdaSachin for the suggestions. @Nodebrute's proposal seems clear and simple. Backend changes aren't necessary as the bug only impacts the front end. We can resolve it using the fix provided by @Nodebrute.

Let's move forward with @Nodebrute's proposal.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

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

@Nodebrute
Copy link
Contributor

@Gonals waiting for assignment

@mallenexpensify
Copy link
Contributor

@Gonals , 👀 please on the proposal above, thx

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

📣 @Nodebrute 🎉 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 📖

@mallenexpensify
Copy link
Contributor

@Gonals , did you hear anything back from this.

I'm back from OOO on Nov 14th, not assigning another BZ cuz payment won't be due before then. If one is needed please add or post in #contributor-plus to ask for one to be added, thx.

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Nov 11, 2024
Copy link

melvin-bot bot commented Nov 11, 2024

This issue has not been updated in over 15 days. @Gonals, @mallenexpensify, @fedirjh, @Nodebrute eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@mallenexpensify
Copy link
Contributor

@Nodebrute can you provide an update plz? Doesn't look like much action's been happening on the PR. Thx
#51008 (comment)

@mallenexpensify mallenexpensify added Daily KSv2 and removed Monthly KSv2 labels Nov 19, 2024
@Nodebrute
Copy link
Contributor

@mallenexpensify The backend no longer archives IOUs from deleted workspaces, which results in users being able to delete the expenses. We will start archiving them again based on this comment. I’m testing it periodically to see if it starts working as expected.

Copy link

melvin-bot bot commented Nov 26, 2024

@Gonals, @mallenexpensify, @fedirjh, @Nodebrute Whoops! This issue is 2 days overdue. Let's get this updated quick!

Copy link

melvin-bot bot commented Nov 28, 2024

@Gonals, @mallenexpensify, @fedirjh, @Nodebrute Eep! 4 days overdue now. Issues have feelings too...

Copy link

melvin-bot bot commented Dec 2, 2024

@Gonals, @mallenexpensify, @fedirjh, @Nodebrute 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

@mallenexpensify mallenexpensify removed the Reviewing Has a PR in review label Dec 2, 2024
@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
@mallenexpensify mallenexpensify added Monthly KSv2 and removed Daily KSv2 labels Dec 2, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 2, 2024
@mallenexpensify
Copy link
Contributor

Thanks @Nodebrute , I made me the issue owner and made it a monthly. If anyone has an update on when we start archiving expenses, please comment.

@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants