Skip to content

[$500] IOU - No error message when changing amount of a paid request #33799

Closed

Description

@izarutskaya

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: v1.4.20-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @

Action Performed:

  1. [User A] Request money from User B.
  2. [User A] Open IOU details page > Click Amount.
  3. [User B] Pay the request.
  4. [User A] Enter a new amount and save it.

Expected Result:

Error message "Unexpected error editing the money request, please try again later" will show up when editing the amount of a settled request.

Actual Result:

Error message does not show up.

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

Bug6328897_1703905910295.bandicam_2023-12-30_03-16-45-208.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01064a73e07695ea66
  • Upwork Job ID: 1741171439973834752
  • Last Price Increase: 2023-12-30
  • Automatic offers:
    • fedirjh | Reviewer | 28077812
    • Pujan92 | Contributor | 28077813

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 30, 2023
  2. changed the title [-] IOU - No error message when changing amount of a paid request[/-] [+][$500] IOU - No error message when changing amount of a paid request[/+] on Dec 30, 2023
  3. melvin-bot commented on Dec 30, 2023

    @melvin-bot
  4. melvin-bot commented on Dec 30, 2023

    @melvin-bot

    Triggered auto assignment to @MitchExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 30, 2023
  6. melvin-bot commented on Dec 30, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Dec 30, 2023

    @melvin-bot

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

  8. neonbhai commented on Dec 30, 2023

    @neonbhai
    Contributor

    Proposal

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

    IOU - No error message when changing amount of a paid request

    What is the root cause of that problem?

    This happens as we don’t check if the request is paid before calling IOU.updateMoneyRequestAmountAndCurrency here:



    const saveAmountAndCurrency = useCallback(
    ({amount, currency: newCurrency}) => {
    const newAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount));
    // If the value hasn't changed, don't request to save changes on the server and just close the modal
    if (newAmount === TransactionUtils.getAmount(transaction) && newCurrency === TransactionUtils.getCurrency(transaction)) {
    Navigation.dismissModal();
    return;
    }
    IOU.updateMoneyRequestAmountAndCurrency(transaction.transactionID, report.reportID, newCurrency, newAmount);
    Navigation.dismissModal();
    },
    [transaction, report],

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

    We should add a check to see if the request is paid using ReportUtils.canEditFieldOfMoneyRequest()
 here:

    // If the value hasn't changed, don't request to save changes on the server and just close the modal
    if (newAmount === TransactionUtils.getAmount(transaction) && newCurrency === TransactionUtils.getCurrency(transaction)) {
    Navigation.dismissModal();
    return;
    }

    We could also use ReportUtils.isSettled() for the check.

    Alternatively:

    • We can add the check in IOU.updateMoneyRequestAmountAndCurrency here.
  9. Tony-MK commented on Dec 31, 2023

    @Tony-MK
    Contributor

    Proposal

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

    What is the root cause of that problem?

    The backend is returning the correct error message, however we don't expect it because we are not handling it in the MoneyRequestView.

    Onyx

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

    Get the errors from the errorFields and set it as the errors prop for the OfflineWithFeedback. The error message should not persist. Therefore, we can delete from the onyx once the user navigates away from the page or onClose. However, if we need them for later, we can also shouldShowErrorMessages if the latest error message is past a certain duration.

    <OfflineWithFeedback pendingAction={getPendingFieldAction('pendingFields.amount')}>
    <MenuItemWithTopDescription

    errors={getLatestAmountCurrencyErrors()}
    

    Pseudo-code

    function getLatestAmountCurrencyErrors(){
     errors = lodashGet(transaction, 'errorFields.amount') || lodashGet(transaction, 'errorFields.currency')
     errors.sort() // If needed 
     return errors.length > 0 ? errors[0] : null
    }
    

    Result

    What alternative solutions did you explore? (Optional)

    1. Create a parent OfflineWithFeedback component of MoneyRequestView. Then, use the transaction.error value for the errors prop of the component.

    2. Listen for the transaction and disable the save button once it's paid. Also, displays an error.

  10. MitchExpensify commented on Dec 31, 2023

    @MitchExpensify
    Contributor

    The expected result is weird to me, why would we tell the user an "unexpected error" occurs if it's expected that you cannot edit a settled amount? Why don't we just tell the user they cannot edit a settled amount if that is indeed expected?

  11. Victor-Nyagudi commented on Jan 1, 2024

    @Victor-Nyagudi
    Contributor

    Is it intentional a user can edit a paid request's amount?

    Wouldn't that lead to conflicts over how much was paid by who later on?

  12. 2 remaining items

  13. Pujan92 commented on Jan 2, 2024

    @Pujan92
    Contributor

    Proposal

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

    No error message shown for updating the paid amount transaction

    What is the root cause of that problem?

    It seems the issue occurs after this PR where we have used a new method to update an amount. For the failure case we don't have any report action error entry which isn't showing any error.

    App/src/libs/actions/IOU.js

    Lines 990 to 1011 in 320ff54

    // Clear out loading states, pending fields, and add the error fields
    failureData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
    value: {
    pendingFields: clearedPendingFields,
    isLoading: false,
    errorFields,
    },
    });
    // Reset the iouReport to it's original state
    failureData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`,
    value: iouReport,
    });
    return {
    params,
    onyxData: {optimisticData, successData, failureData},
    };

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

    Add an entry for the failureData in the onyx which sets error to that specific report action.

        failureData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread.reportID}`,
            value: {
                [updatedReportAction.reportActionID]: {
                    errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericEditFailureMessage'),
                },
            },
        })
    

    Like we have for the older method

    App/src/libs/actions/IOU.js

    Lines 2195 to 2203 in 320ff54

    const failureData = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread.reportID}`,
    value: {
    [updatedReportAction.reportActionID]: {
    errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericEditFailureMessage'),
    },
    },

    Result
    Screen.Recording.2024-01-02.at.16.28.17.mp4
  14. fedirjh commented on Jan 2, 2024

    @fedirjh
    Contributor

    @Pujan92 Thank you for the proposal, the root cause looks correct. I just retested with reverting #32533 and it's working as expected.

    For the solution, it looks good to me, I believe we should add the failure data inside getUpdateMoneyRequestParams to fix the bug with other fields as well.

    🎀 👀 🎀 C+ reviewed

  15. melvin-bot commented on Jan 2, 2024

    @melvin-bot

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

  16. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 2, 2024
  17. melvin-bot commented on Jan 2, 2024

    @melvin-bot

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

  18. melvin-bot commented on Jan 2, 2024

    @melvin-bot

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

  19. added
    ReviewingHas a PR in review
    and removed on Jan 3, 2024
  20. fedirjh commented on Jan 9, 2024

    @fedirjh
    Contributor

    Update: PR was merged and deployed to production #33880 (comment). It seems automation was not triggered for this one.

  21. Pujan92 commented on Jan 25, 2024

    @Pujan92
    Contributor
  22. MitchExpensify commented on Jan 27, 2024

    @MitchExpensify
    Contributor

    Payment summary::

    Paid and contracts ended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions