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] Expense - Edited amount for a paid request does not revert to paid amount when dismiss the error #54471

Open
2 of 8 tasks
vincdargento opened this issue Dec 23, 2024 · 10 comments
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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@vincdargento
Copy link

vincdargento commented Dec 23, 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: v9.0.77-6
Reproducible in staging?: Yes
Reproducible in production?: Yes
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: N/A
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team

Action Performed:

  1. Navigate to staging.new.expensify.com.
  2. [User A] Request money from User B.
  3. [User A] Open IOU details page > Click Amount.
  4. [User B] Pay the request.
  5. [User A] Enter a new amount and save it.
  6. [User A] Close the error message.

Expected Result:

The amount in IOU details page should revert to the original amount after closing the error message (as in PR #32898)

Actual Result:

The amount in IOU details page does not revert to the original amount after closing the error message. It only reverts after refreshing the app.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021871573512679466358
  • Upwork Job ID: 1871573512679466358
  • Last Price Increase: 2024-12-24
Issue OwnerCurrent Issue Owner: @hungvu193
@vincdargento vincdargento added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 23, 2024
Copy link

melvin-bot bot commented Dec 23, 2024

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

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 23, 2024

Edited by proposal-police: This proposal was edited at 2024-12-23 19:30:42 UTC.

Proposal

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

The amount in IOU details page does not revert to the original amount after closing the error message. It only reverts after refreshing the app.

What is the root cause of that problem?

We only update the pending field and error field of transactions in failureData. Then the updated data isn't reverted.

App/src/libs/actions/IOU.ts

Lines 2992 to 3000 in 2458635

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: clearedPendingFields,
isLoading: false,
errorFields,
},
});

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

We should revert to original transaction data and only override the pending field and error field. Or we can simply revert to transaction

failureData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
    value: {
        ...transaction,
        pendingFields: clearedPendingFields,
        isLoading: false,
        errorFields,
    },
});

Or

failureData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
    value: transaction,
});

App/src/libs/actions/IOU.ts

Lines 2992 to 3000 in 2458635

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: clearedPendingFields,
isLoading: false,
errorFields,
},
});

We can check if getUpdateTrackExpenseParams has the same problem and fix it

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

We must create a unit test for one of the update money request APIs, making the request fail. After that we need to verify the transaction data is reverted to the original value before the API is called.

What alternative solutions did you explore? (Optional)

NA

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.

@Tony-MK
Copy link
Contributor

Tony-MK commented Dec 23, 2024

Proposal

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

Expense - Edited amount for a paid request does not revert to paid amount when dismissing the error

What is the root cause of that problem?

We are not returning the transaction amount figure back to the original amount and will take the figure from modifiedAmount since it is not empty.

clearError={Transaction.clearError}

So, we any clear the errors but we don't revert the transaction changes.

function clearError(transactionID: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {errors: null, errorFields: {route: null, waypoints: null, routes: null}});
}

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

Create a new function for the clearError prop, over here, to revert the transaction data to the previous values depending on which field was attempted to change while calling Transaction.clearError.

We will revert the transaction values from the report's modified Expense action originalMessage.

clearError={
 (transactionID) => {
  // Revert the transaction values from reportAction.originalMessage
  Transaction.clearError(transactionID)
 }
}

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

Create a unit test for the new function to check if it can restore the previous values of the transaction even with different changes.

What alternative solutions did you explore? (Optional)

Let's update the failureData and add the previous values of the transaction, in this case, the amount, modified amount, etc...

@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Dec 24, 2024
@melvin-bot melvin-bot bot changed the title Expense - Edited amount for a paid request does not revert to paid amount when dismiss the error [$250] Expense - Edited amount for a paid request does not revert to paid amount when dismiss the error Dec 24, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 24, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

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

@bfitzexpensify bfitzexpensify moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 24, 2024
@hungvu193
Copy link
Contributor

hungvu193 commented Dec 25, 2024

Thanks for the proposals, everyone.
Both proposals make sense to me.

As described in the expected result, we should revert the edited amount after closing error message. Because of that I'm aligned with @Tony-MK 's proposal.

🎀👀🎀

Copy link

melvin-bot bot commented Dec 25, 2024

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

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 25, 2024

Verify you will get an error message
Verify the amount is reverted to the paid amount

@hungvu193 Based on the PR mentioned in OP, the expected amount is reverted immediately after we get an error message. You also can see other patterns of the App like editing comments, and edit task title/description it also reverts immediately after the API fails.

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 25, 2024

@tylerkaraszewski, please wait for the assignment until we clarify what is expected.

@hungvu193
Copy link
Contributor

I'm fine with both solutions:

Screenshot 2024-12-26 at 09 40 39

cc @tylerkaraszewski and @bfitzexpensify for the expected behavior here.

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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants