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 #48400][$250] Expense - RBR doesn't disappear Instantly after paying held expense #48397

Closed
2 of 6 tasks
IuliiaHerets opened this issue Sep 2, 2024 · 33 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Sep 2, 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.27-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. As User A, go to the chat with User B.
  3. As User A, submit an expense.
  4. As User A, right-click on the expense and click "Hold."
  5. The RBR appears in the expense preview for both User A and User B. If not, go to the expense details and then return to the chat.
  6. As User B, click "Pay Elsewhere" and confirm the payment.
  7. Click on the expense preview and then return to the chat (repeat this for both User A and User B).

Expected Result:

After paying the held expense in step 6, the RBR in the preview should disappear instantly.

Actual Result:

After paying the held expense in step 6, the RBR in the preview persists. The red dot only disappears after clicking on the preview and returning to the chat.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6589914_1725218970132!1 (1)

Bug6589914_1725218970132.1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021831729851068678041
  • Upwork Job ID: 1831729851068678041
  • Last Price Increase: 2024-09-19
  • Automatic offers:
    • ikevin127 | Reviewer | 104042668
    • nkdengineer | Contributor | 104042669
Issue OwnerCurrent Issue Owner: @twisterdotcom
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 2, 2024
Copy link

melvin-bot bot commented Sep 2, 2024

Triggered auto assignment to @twisterdotcom (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
Copy link
Author

We think that this bug might be related to #vip-bills

@IuliiaHerets
Copy link
Author

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

@Nodebrute
Copy link
Contributor

Nodebrute commented Sep 2, 2024

Edited by proposal-police: This proposal was edited at 2024-09-02 13:47:25 UTC.

Proposal

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

RBR doesn't disappear Instantly after paying held expense

What is the root cause of that problem?

In getPayMoneyRequestParams, we unhold transactions when we process a payment, but we don't clear transaction violation("hold"). This is why we're still seeing RBR.

App/src/libs/actions/IOU.ts

Lines 6725 to 6734 in 9aca655

for (const transaction of reportTransactions) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
comment: {
hold: null,
},
},
});

Screenshot 2024-09-02 at 6 31 18 PM

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

We should also clear the transaction violation "hold" here. We can do something like this

            const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`]
optimisticData.push({
                onyxMethod: Onyx.METHOD.SET,
                key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
                value: transactionViolations?.filter((violation) => violation.name !== CONST.VIOLATIONS.HOLD) ?? []
            })

We also need to include failure data here.

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Sep 4, 2024
@twisterdotcom
Copy link
Contributor

Yes, I recreated this.

rbr.expense.mp4

@melvin-bot melvin-bot bot removed the Overdue label Sep 5, 2024
@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Sep 5, 2024
Copy link

melvin-bot bot commented Sep 5, 2024

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

@melvin-bot melvin-bot bot changed the title Expense - RBR doesn't disappear Instantly after paying held expense [$250] Expense - RBR doesn't disappear Instantly after paying held expense Sep 5, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 5, 2024
Copy link

melvin-bot bot commented Sep 5, 2024

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

@nkdengineer
Copy link
Contributor

Proposal

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

After paying the held expense in step 6, the RBR in the preview persists. The red dot only disappears after clicking on the preview and returning to the chat.

What is the root cause of that problem?

When we pay money request, we unhold all transactions. But we don't clear the hold violation in optimistic data and after the API is complete, BE also doesn't clear the hold violation of the transaction then RBR still displays.

App/src/libs/actions/IOU.ts

Lines 6725 to 6734 in 65c0f41

if (full) {
const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport.reportID);
for (const transaction of reportTransactions) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
comment: {
hold: null,
},

This bug also happens when we approve money request but it only happens in offline, after the API is complete, BE returns violation of transaction that cleared the hold violation

App/src/libs/actions/IOU.ts

Lines 7018 to 7023 in 65c0f41

heldTransactions.forEach((heldTransaction) => {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`,
value: {
comment: {

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

We should clear the hold violation when we pay/approve all requests. To prevent duplicate code, we can create a util to get the optimistic data for this case

function buildOnyxDataForUnHoldTransaction(expenseReport: OnyxEntry<OnyxTypes.Report>) {
    const optimisticData: OnyxUpdate[] = [];
    const failureData: OnyxUpdate[] = [];

    const heldTransactions = ReportUtils.getAllHeldTransactions(expenseReport?.reportID);
    heldTransactions.forEach((heldTransaction) => {
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`,
            value: {
                comment: {
                    hold: '',
                },
            },
        });
        failureData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`,
            value: {
                comment: {
                    hold: heldTransaction.comment?.hold,
                },
            },
        });
        const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${heldTransaction.transactionID}`] ?? []
        optimisticData.push({
            onyxMethod: Onyx.METHOD.SET,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${heldTransaction.transactionID}`,
            value: transactionViolations.filter((violation) => violation.name !== CONST.VIOLATIONS.HOLD)
        });
        failureData.push({
            onyxMethod: Onyx.METHOD.SET,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${heldTransaction.transactionID}`,
            value: transactionViolations,
        });
    });

    return {optimisticData, failureData};
}

Then we can use this in both places here

if (full) {
    const unholdTransactionOnyxData = buildOnyxDataForUnHoldTransaction(iouReport);
    optimisticData.push(...unholdTransactionOnyxData.optimisticData);
    failureData.push(...unholdTransactionOnyxData.failureData);
}

App/src/libs/actions/IOU.ts

Lines 6725 to 6734 in 65c0f41

if (full) {
const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport.reportID);
for (const transaction of reportTransactions) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
comment: {
hold: null,
},

if (full && hasHeldExpenses) {
    const unholdTransactionOnyxData = buildOnyxDataForUnHoldTransaction(expenseReport);
    optimisticData.push(...unholdTransactionOnyxData.optimisticData);
    failureData.push(...unholdTransactionOnyxData.failureData);
}

App/src/libs/actions/IOU.ts

Lines 7018 to 7023 in 65c0f41

heldTransactions.forEach((heldTransaction) => {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`,
value: {
comment: {

OPTIONAL: BE should also clear the hold violation when returning the data in PayMoneyRequest API

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Sep 10, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Sep 10, 2024
@twisterdotcom
Copy link
Contributor

@abdulrahuman5196 how are we doing on the reviews here?

@melvin-bot melvin-bot bot removed the Overdue label Sep 10, 2024
Copy link

melvin-bot bot commented Sep 12, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Sep 13, 2024
@abdulrahuman5196
Copy link
Contributor

abdulrahuman5196 commented Sep 16, 2024

Hi @twisterdotcom, I am having multiple items on my plate. Kindly assign it to a different C+. Unassigning myself.

@melvin-bot melvin-bot bot removed the Overdue label Sep 16, 2024
@abdulrahuman5196 abdulrahuman5196 removed their assignment Sep 16, 2024
@twisterdotcom twisterdotcom added External Added to denote the issue can be worked on by a contributor and removed External Added to denote the issue can be worked on by a contributor labels Sep 16, 2024
Copy link

melvin-bot bot commented Sep 16, 2024

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 19, 2024
Copy link

melvin-bot bot commented Sep 19, 2024

📣 @ikevin127 🎉 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

Copy link

melvin-bot bot commented Sep 19, 2024

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

@cead22
Copy link
Contributor

cead22 commented Sep 19, 2024

@thienlnam this might be a duplicate of #48400. I think we should fix it now, and if it's a dupe we can handle it in that other issue

@thienlnam
Copy link
Contributor

Ah yeah, actually this does look like a dupe and the other issue already has an assignee

@thienlnam thienlnam changed the title [$250] Expense - RBR doesn't disappear Instantly after paying held expense [HOLD #48400][$250] Expense - RBR doesn't disappear Instantly after paying held expense Sep 19, 2024
@nkdengineer
Copy link
Contributor

@cead22 I think we should clear the hold violation in optimistic data if we paid full instead of adding !isSettled condition.

@ikevin127
Copy link
Contributor

ikevin127 commented Sep 20, 2024

There's a 3rd dupe of this issue that might be fixed in similar fashion, only difference being it's a split instead of hold:

Please confirm if this would be fixed by selected proposal from #48400 so we know whether to close it.

Copy link

melvin-bot bot commented Sep 24, 2024

@twisterdotcom, @thienlnam, @ikevin127 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Sep 24, 2024
@thienlnam
Copy link
Contributor

@ikevin127 That looks like it would also be solved by #48400

The steps don't look reproducible because it's probably because the expense needs to have a violation

@thienlnam thienlnam added Weekly KSv2 and removed Daily KSv2 Overdue labels Sep 24, 2024
@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

This issue has not been updated in over 15 days. @twisterdotcom, @thienlnam, @ikevin127 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!

@dylanexpensify dylanexpensify moved this to Release 3: Fall 2024 (Nov) in [#whatsnext] #expense Oct 18, 2024
@twisterdotcom
Copy link
Contributor

#48400 is closed now so I'll try to retest this.

@twisterdotcom twisterdotcom added Daily KSv2 and removed Monthly KSv2 labels Oct 21, 2024
@melvin-bot melvin-bot bot added the Overdue label Oct 24, 2024
@ikevin127
Copy link
Contributor

Retesting.

@twisterdotcom
Copy link
Contributor

Yeah, fixed.

48397.mp4

@melvin-bot melvin-bot bot removed the Overdue label Oct 25, 2024
@github-project-automation github-project-automation bot moved this from Release 3: Fall 2024 (Nov) to Done in [#whatsnext] #expense Oct 25, 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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Archived in project
Development

No branches or pull requests

8 participants