Skip to content

[HOLD for payment 2024-01-11] [$250] IOU - System message for merchant edit shows up for each time empty merchant is saved #33780

Closed

Description

@lanitochka17

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: 1.4.20-0
Reproducible in staging?: Y
Reproducible in production?: N
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. Create a manual request with no merchant as IOU report (between two users)
  2. Go to request details page
  3. Click Merchant
  4. Without entering value, save it

Expected Result:

No system message for merchant edit will appear because there is no change in Merchant

Actual Result:

Each time the empty merchant is saved, the system message for merchant edit will show up - changed the merchant to "(none)" (previously "(none)"

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

Bug6328700_1703879718303.bandicam_2023-12-30_02-31-24-786__1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0109648360ee115912
  • Upwork Job ID: 1740852361151582208
  • Last Price Increase: 2023-12-29
  • Automatic offers:
    • abzokhattab | Contributor | 28073105
Issue OwnerCurrent Issue Owner: @garrettmknight

Activity

  1. github-actions commented on Dec 29, 2023

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  2. melvin-bot commented on Dec 29, 2023

    @melvin-bot

    Triggered auto assignment to @Beamanator (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

  3. abzokhattab commented on Dec 29, 2023

    @abzokhattab
    Contributor

    Proposal

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

    The system message for merchant edit shows up each time an empty merchant is saved

    What is the root cause of that problem?

    in the onSubmit function we check if the old merchant value equals the new merchant value then the modal should be dismissed, however in our case this condition fails because the old merchant value is (none) and the new value when saving without change is `` (empty string)

    // In case the merchant hasn't been changed, do not make the API request.
    if (transactionChanges.merchant.trim() === transactionMerchant) {
    Navigation.dismissModal();
    return;
    }

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

    We need to consider this corner case and dismiss the modal without calling the backend:

           if (
                            transactionChanges.merchant.trim() === transactionMerchant ||
                            (transactionChanges.merchant.trim() === '' && transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)
                        ) {
                            Navigation.dismissModal();
                            return;
                        }

    we can also refactor the onSubmit function to be like this:

    onSubmit={(transactionChanges) => {
        const newTrimmedMerchant = transactionChanges.merchant.trim();
        const isOldMerchantEmpty = transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
        const isNewMerchantEmpty = newTrimmedMerchant === '';
    
        // Check if merchant is unchanged or if new merchant is empty for an empty old merchant
        const isMerchantUnchanged = newTrimmedMerchant === transactionMerchant || (isNewMerchantEmpty && isOldMerchantEmpty);
    
        // Dismiss modal if merchant hasn't changed
        if (isMerchantUnchanged) {
            Navigation.dismissModal();
            return;
        }
    
        // Handle IOU requests for empty new merchant
        if (isNewMerchantEmpty) {
            editMoneyRequest({ merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT });
            return;
        }
    
        // Update the merchant for other cases
        editMoneyRequest({ merchant: newTrimmedMerchant });
    }}
  4. mountiny commented on Dec 29, 2023

    @mountiny
    Contributor

    @waterim @koko57 this is one usecase we have missed in the PR

  5. self-assigned this
    on Dec 29, 2023
  6. mountiny commented on Dec 29, 2023

    @mountiny
    Contributor

    @abzokhattab Do you fancy being C+ on the PR for $250? I will put up the fix and you will do testing and review? Its a simple PR but the authors are out

  7. abzokhattab commented on Dec 29, 2023

    @abzokhattab
    Contributor

    @mountiny sure!

  8. deleted a comment from melvin-bot on Dec 29, 2023
  9. 35 remaining items

  10. melvin-bot commented on Jan 5, 2024

    @melvin-bot

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

  11. deleted a comment from melvin-bot on Jan 5, 2024
  12. mountiny commented on Jan 5, 2024

    @mountiny
    Contributor

    $250 to @abzokhattab for help with review and testing the PR

  13. garrettmknight commented on Jan 8, 2024

    @garrettmknight
    Contributor

    Will update payment on 1/11

  14. garrettmknight commented on Jan 11, 2024

    @garrettmknight
    Contributor

    Paid!

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions