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 2024-08-13] [$250] Split - App allows splitting when the sum of splits is not equal to the total amount #45199

Closed
6 tasks done
lanitochka17 opened this issue Jul 10, 2024 · 29 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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

@lanitochka17
Copy link

lanitochka17 commented Jul 10, 2024

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: 9.0.6-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4706187
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to a group chat
  3. Click + > Split expense > Manual
  4. Enter amount > Next
  5. On confirmation page, enter 0 on the split input on each participant
  6. Click Merchant
  7. Enter any merchant and save it
  8. Click Split

Expected Result:

App will not allow splitting when the sum of splits is not equal to the total amount

Actual Result:

App allows splitting when the sum of splits is not equal to the total amount after saving merchant or description.
This issue only issues after saving merchant or description

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

Bug6538142_1720631295192.20240711_010228.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01aa3c722d2bc20e70
  • Upwork Job ID: 1813311970667167974
  • Last Price Increase: 2024-07-23
  • Automatic offers:
    • rayane-djouah | Reviewer | 103237152
    • Krishna2323 | Contributor | 103237156
Issue OwnerCurrent Issue Owner: @adelekennedy
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

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

@lanitochka17
Copy link
Author

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

@lanitochka17
Copy link
Author

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

@abzokhattab
Copy link
Contributor

abzokhattab commented Jul 10, 2024

Proposal

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

App doesn't show the invalid sum error when navigating to the description or merchant then going back

What is the root cause of that problem?

  • when changing the merchant/description in the confirmation page, the transactionand isFocused change which triggers the following useEffect which clears the error message if none of these conditions if fulfilled.

    useEffect(() => {
    if (shouldDisplayFieldError && didConfirmSplit) {
    setFormError('iou.error.genericSmartscanFailureMessage');
    return;
    }
    if (shouldDisplayFieldError && hasSmartScanFailed) {
    setFormError('iou.receiptScanningFailed');
    return;
    }
    // reset the form error whenever the screen gains or loses focus
    setFormError('');
    // eslint-disable-next-line react-hooks/exhaustive-deps -- we don't want this effect to run if it's just setFormError that changes
    }, [isFocused, transaction, shouldDisplayFieldError, hasSmartScanFailed, didConfirmSplit]);

  • thesetFormError(''); line was added in this PR to prevent creating distance requests with very big rate number. however this line is not needed since it clears the error in the first place when navigating to description or merchant .. and this is not needed

Screen.Recording.2024-07-19.at.9.58.55.AM.mov

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

we can remove the setFormError(''); as it clears the error when navigating to the description page .. so removing this line will prevent it from clearing the error on changing the description or the merchant.

alternatively

we can keep the previous setFormError(''); and set we should add additional dependencies likeisFocused,transactionto the useEffect that triggers the invalid sum error just like we do here and here , so that the useEffect gets triggered when refocusing

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jul 10, 2024

Proposal

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

Split - App allows splitting when the sum of splits is not equal to the total amount

What is the root cause of that problem?

  1. The functionality to clear the error message was added in this PR
    // reset the form error whenever the screen gains or loses focus
    setFormError('');
  2. The PR was focused on showing error on confirmation page if the total amount of the distance rate is invalid. If the mi/km multiply by distance rate is greater then the limit it will show Invalid Amount error.
    const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode);
    if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(iouAmount), decimals)) {
    setFormError('common.error.invalidAmount');
    return;
    }
  3. If we don't clear the form error when screen losses focus or gains, we will be not able to create the transaction after invalid amount error is shown and we update the rate to the correct one.
Monosnap.screencast.2024-07-19.08-40-13.mp4
  1. Every other form error is show as expected because for the form errors we use useEffect with isFocused and transaction as the dependencies, so whenever the focus is changed or transaction is updated the error is recalculated and updated.
    useEffect(() => {
    if (shouldDisplayFieldError && didConfirmSplit) {
    setFormError('iou.error.genericSmartscanFailureMessage');
    return;
    }
    if (shouldDisplayFieldError && hasSmartScanFailed) {
    setFormError('iou.receiptScanningFailed');
    return;
    }
    // reset the form error whenever the screen gains or loses focus
    setFormError('');
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps -- we don't want this effect to run if it's just setFormError that changes
    }, [isFocused, transaction, shouldDisplayFieldError, hasSmartScanFailed, didConfirmSplit]);
  2. But in the useEffect where we re-calculate the errors for split we haven't added isFocused and transaction as the dependencies, so the function doesn't run after screen gets focused or transaction changes.
    }, [isTypeSplit, transaction?.splitShares, iouAmount, iouCurrencyCode, setFormError, translate]);

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

We can't remove setFormError(''); because it will re-create this issue, we need to add isFocused and transaction as the useEffect dependencies.

}, [isTypeSplit, transaction?.splitShares, iouAmount, iouCurrencyCode, setFormError, translate]);

What alternative solutions did you explore? (Optional)

When we update the rate the distance amount is recalculated in a useEffect, we can use that useEffect for updating the error message and then we can remove setFormError('');

useEffect(() => {
if (!shouldCalculateDistanceAmount) {
return;
}
const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0);
IOU.setMoneyRequestAmount(transactionID, amount, currency ?? '');
}, [shouldCalculateDistanceAmount, distance, rate, unit, transactionID, currency]);

    useEffect(() => {
        if (!shouldCalculateDistanceAmount) {
            return;
        }

        const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0);
        IOU.setMoneyRequestAmount(transactionID, amount, currency ?? '');

        const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode);
        if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(amount), decimals)) {
            setFormError('common.error.invalidAmount');
            return;
        }

        setFormError('');
    }, [shouldCalculateDistanceAmount, distance, rate, unit, transactionID, currency, isDistanceRequest, iouCurrencyCode, isDistanceRequestWithPendingRoute, setFormError]);

@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2024
Copy link

melvin-bot bot commented Jul 16, 2024

@adelekennedy Huh... This is 4 days overdue. Who can take care of this?

@adelekennedy
Copy link

reproduced!

@melvin-bot melvin-bot bot removed the Overdue label Jul 16, 2024
@adelekennedy adelekennedy added External Added to denote the issue can be worked on by a contributor Overdue labels Jul 16, 2024
Copy link

melvin-bot bot commented Jul 16, 2024

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

@melvin-bot melvin-bot bot changed the title Split - App allows splitting when the sum of splits is not equal to the total amount [$250] Split - App allows splitting when the sum of splits is not equal to the total amount Jul 16, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 16, 2024
Copy link

melvin-bot bot commented Jul 16, 2024

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

@adelekennedy
Copy link

@rayane-djouah two proposals to review above!

@Krishna2323
Copy link
Contributor

@rayane-djouah, FYI, the proposal here was updated after I posted my proposal. Please make sure to check the edit history before selecting a proposal.

Before my proposal it stated we should add the isFocused to the useEffect dependencies and after my proposal it was changed to we should add additional dependencies like isFocused to the useEffect dependencies.

@rayane-djouah
Copy link
Contributor

Reviewing now

@rayane-djouah
Copy link
Contributor

Thank you for the proposals, everyone, can you please explain in your RCA why the form error is cleared when saving merchant/description? having a solid RCA will help us make the right changes

@abzokhattab
Copy link
Contributor

Thanks for the review @rayane-djouah, updated my proposal with another solution.

@Krishna2323
Copy link
Contributor

@rayane-djouah, proposal updated to include more detailed RCA. Added an alternative solution also.

@abzokhattab
Copy link
Contributor

Proposal updated

same solution but updated the RCA

Copy link

melvin-bot bot commented Jul 22, 2024

@adelekennedy, @rayane-djouah Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Jul 22, 2024
@rayane-djouah
Copy link
Contributor

Reviewing proposals

@melvin-bot melvin-bot bot removed the Overdue label Jul 22, 2024
@rayane-djouah
Copy link
Contributor

@Krishna2323's proposal looks good to me

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 23, 2024

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

Copy link

melvin-bot bot commented Jul 23, 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 removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 23, 2024
Copy link

melvin-bot bot commented Jul 23, 2024

📣 @rayane-djouah 🎉 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 Jul 23, 2024

📣 @Krishna2323 🎉 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 Jul 24, 2024

@tylerkaraszewski @adelekennedy @rayane-djouah @Krishna2323 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@Krishna2323
Copy link
Contributor

@rayane-djouah, PR ready for review ^

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 6, 2024
@melvin-bot melvin-bot bot changed the title [$250] Split - App allows splitting when the sum of splits is not equal to the total amount [HOLD for payment 2024-08-13] [$250] Split - App allows splitting when the sum of splits is not equal to the total amount Aug 6, 2024
Copy link

melvin-bot bot commented Aug 6, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 6, 2024
Copy link

melvin-bot bot commented Aug 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.16-8 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 2024-08-13. 🎊

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

Copy link

melvin-bot bot commented Aug 6, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@rayane-djouah] The PR that introduced the bug has been identified. Link to the PR:
  • [@rayane-djouah] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@rayane-djouah] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@rayane-djouah] Determine if we should create a regression test for this bug.
  • [@rayane-djouah] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@adelekennedy] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 12, 2024
@rayane-djouah
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: [HOLD] Implement Uneven Splits #40386
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/40386/files#r1715756785
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug. Yes
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Proposal

  1. Go to a group chat
  2. Click + > Split expense > Manual
  3. Enter amount > Next
  4. On the confirmation page, enter 0 on the split input for each participant
  5. Verify there is an error The sum of splits must be equal to the amount.
  6. Click Merchant
  7. Enter any merchant and save it
  8. Verify the error is still there and nothing happens when clicking confirm button.

Do we agree 👍 or 👎

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

6 participants