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

[HOLD for payment 2025-01-02] [$250] Hold - Hold banner shows up after deleting dupe expense #53651

Open
1 of 8 tasks
lanitochka17 opened this issue Dec 5, 2024 · 32 comments
Open
1 of 8 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Dec 5, 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.72-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: #53167
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Precondition: Create a workspace and invite a user as employee.

  1. [Employee] Submit two expenses that are duplicated
  2. [Admin] Go to the transaction thread of a transaction
  3. [Admin] Review the duplicate and choose any the first transaction to keep
  4. [Employee] Open expense report
  5. [Employee] Right click on the second transaction and delete it (The one that is on hold)

Expected Result:

Hold banner doesn't show up since there is no transaction that is on hold at the moment

Actual Result:

Hold banner appears even if there is no transaction on hold

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6685478_1733424577498.bandicam_2024-12-05_21-39-33-560.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021865063509444295109
  • Upwork Job ID: 1865063509444295109
  • Last Price Increase: 2024-12-06
  • Automatic offers:
    • dominictb | Contributor | 105259939
    • FitseTLT | Contributor | 105373054
Issue OwnerCurrent Issue Owner: @trjExpensify
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 5, 2024
Copy link

melvin-bot bot commented Dec 5, 2024

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

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 5, 2024

Edited by proposal-police: This proposal was edited at 2024-12-05 20:44:02 UTC.

Proposal

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

Hold - Hold banner shows up after deleting dupe expense

What is the root cause of that problem?

There are two problems here if both the admin account and employee account are new accounts where they haven't dismissedHoldUseExplanation yet

  1. From the Admin side, when we open the first transaction thread and resolve the duplicate. The second transactionThread report is not available in onyx (until we open it). So when we resolve the duplicate the transactionID here will -1 because we are using TransactionUtils.getTransactionID to indirectly get transactionID which requires the availablity of the transaction thread that is to be put on hold (in this case the second transaction thread)
    const transactionID = TransactionUtils.getTransactionID(transactionThreadReportID ?? '-1');

    so we set comment.hold on a tranasaction_-1 key so whenever we open the money report with two transaction thread the transactionThreadReportID will be -1
    const transaction =
    transactions?.[
    `${ONYXKEYS.COLLECTION.TRANSACTION}${
    ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? -1 : -1
    }`
    ] ?? undefined;

    so the isHold will be true as we have set hold on transactionID -1 and hence the banner is shown every time we open the money report until hold use explanation is dismissed
  2. From the employee side after the admin has resolved the duplicate transactions if we delete the held expense the hold menu will be shown because the transactionViolation for the first transaction is not immediately pushed from BE and the first transaction in onyx will have duplicate violation (until page refresh on which the data will be successfully fetched from BE) so the modal will be shown not for the second transaction but for the second one. This one can only be fixed in BE.

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

Solution for problem 1: We should directly get the transaction id from iou action (parent actioninstead of indirectly viaTransactionUtils.getTransactionIDhttps://github.com/Expensify/App/blob/4eb86b4435761c97f4c7257dd7e03ac565274d53/src/libs/actions/IOU.ts#L8574-L8578 because we don't needtransactionThreadReportIDList` anymore we will directly iterate on iouActionList like:

iouActionList.forEach((action ) => {
        const transactionThreadReportID = action?.childReportID;
        const createdReportAction = ReportUtils.buildOptimisticHoldReportAction();
        reportActionIDList.push(createdReportAction.reportActionID);
        const transactionID = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID ?? '-1' : '-1';

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

We can make a test for resolveDuplicates by setting the appropriate value in onyx (of course without setting the second transactionThread report in onyx) and also passing the correct params and then assert that it correctly sets the second transaction on hold and also it doesn't set the hold for transactioin_-1

What alternative solutions did you explore? (Optional)

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 6, 2024

Proposal

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

Hold banner appears even if there is no transaction on hold

What is the root cause of that problem?

  1. The transaction thread report is unavailable in Onyx from the admin side until the admin opens this report. When we resolve the duplicate and choose the first transaction, transactionID of the second transaction is wrong here because we're getting this based on the data of the transaction thread report which is unavailable as I mentioned above.

const transactionID = TransactionUtils.getTransactionID(transactionThreadReportID ?? '-1');

function getTransactionID(threadReportID: string): string {
const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${threadReportID}`] ?? null;
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? '');
const IOUTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';

  1. After the admin resolves the duplicate, the backend doesn't send a pusher to remove the duplicate violation then the employee still sees the duplicate. When the second transaction is deleted, the expense report becomes the combine report so the hold banner appears.

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

  1. We already have orderedTransactionIDList here that has the same order with transactionThreadReportIDList, we can use it here
transactionThreadReportIDList.forEach((transactionThreadReportID, index) => {
    const transactionID = orderedTransactionIDList?.at(index) ?? '-1';

const transactionID = TransactionUtils.getTransactionID(transactionThreadReportID ?? '-1');

  1. For the second problem, we should fix it from the backend side to send the pusher to clear the duplicate violation after the admin resolves the duplicate.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

We can create an API test with resolveDuplicates. We need to prepare the corresponding Onyx data (the data that cause this issue) after we call this API, we need to verify that all resolved transactions are holds expect the selected transaction in resolveDuplicates

@trjExpensify trjExpensify added the External Added to denote the issue can be worked on by a contributor label Dec 6, 2024
@melvin-bot melvin-bot bot changed the title Hold - Hold banner shows up after deleting dupe expense [$250] Hold - Hold banner shows up after deleting dupe expense Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 6, 2024
@trjExpensify trjExpensify moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@trjExpensify trjExpensify assigned dominictb and unassigned ntdiary Dec 9, 2024
@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Dec 9, 2024
Copy link

melvin-bot bot commented Dec 9, 2024

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

Copy link

melvin-bot bot commented Dec 10, 2024

@trjExpensify, @dominictb Whoops! This issue is 2 days overdue. Let's get this updated quick!

@trjExpensify
Copy link
Contributor

@dominictb what do you think of the above?

@melvin-bot melvin-bot bot removed the Overdue label Dec 10, 2024
@dominictb
Copy link
Contributor

@trjExpensify I'm reviewing both proposals but need more time for testing. Will provide update in several hours.

@trjExpensify
Copy link
Contributor

trjExpensify commented Dec 11, 2024 via email

@melvin-bot melvin-bot bot added the Overdue label Dec 13, 2024
@trjExpensify
Copy link
Contributor

@dominictb can we get an update, please? Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Dec 16, 2024
@dominictb
Copy link
Contributor

on it now

@dominictb

This comment was marked as outdated.

@FitseTLT
Copy link
Contributor

@dominictb Updated 👍

@dominictb
Copy link
Contributor

@FitseTLT's proposal looks good to me.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Dec 17, 2024

Current assignee @carlosmiceli is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@dominictb
Copy link
Contributor

@carlosmiceli We also need BE fix to handle the second issue mentioned in here

@FitseTLT
Copy link
Contributor

@carlosmiceli We also need BE fix to handle the second issue mentioned in here

But the FE fix is independent to the BE fix so we can start on the PR as soon as you assign me 👍

Copy link

melvin-bot bot commented Dec 17, 2024

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

@carlosmiceli
Copy link
Contributor

From the employee side after the admin has resolved the duplicate transactions if we delete the held expense the hold menu will be shown because the transactionViolation for the first transaction is not immediately pushed from BE and the first transaction in onyx will have duplicate violation (until page refresh on which the data will be successfully fetched from BE) so the modal will be shown not for the second transaction but for the second one. This one can only be fixed in BE.

@cead22 @pecanoro since you both have worked in violations, maybe you want to work on this or can think of someone that would be a good fit at the moment? I have little context/bandwidth right now, but can work on it down the road if we don't think it's urgent.

@cead22
Copy link
Contributor

cead22 commented Dec 17, 2024

I don't have time right now, but this should be relatively straightforward. We just need to push the (empty) violations for the transaction in question from PHP when deleting a transaction

@dominictb
Copy link
Contributor

Waiting for @FitseTLT's PR

@pecanoro
Copy link
Contributor

I agree with @cead22. I would say even you can push the empty violations for the transaction from Auth when being deleted. I think there is a couple of examples in the codebase where we do that.

@carlosmiceli
Copy link
Contributor

@cead22 @pecanoro cool, I'll work on it, just need a couple of days before I can get to it 👍

@carlosmiceli carlosmiceli added Weekly KSv2 Daily KSv2 and removed Daily KSv2 Weekly KSv2 labels Dec 18, 2024
@dominictb
Copy link
Contributor

@FitseTLT Friendly bump!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 Weekly KSv2 labels Dec 20, 2024
@melvin-bot melvin-bot bot changed the title [$250] Hold - Hold banner shows up after deleting dupe expense [HOLD for payment 2025-01-02] [$250] Hold - Hold banner shows up after deleting dupe expense Dec 26, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 26, 2024
Copy link

melvin-bot bot commented Dec 26, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Dec 26, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.78-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-01-02. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Dec 26, 2024

@dominictb @trjExpensify @dominictb The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@garrettmknight garrettmknight moved this from Bugs and Follow Up Issues to Hold for Payment in [#whatsnext] #expense Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
Status: Hold for Payment
Development

No branches or pull requests

9 participants