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-02-05] [$500] IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page #33125

Closed
6 tasks done
lanitochka17 opened this issue Dec 14, 2023 · 39 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Dec 14, 2023

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.13.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:
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. Go to staging.new.expensify.com.
  2. Click FAB > Request money > Manual.
  3. Enter amount and select a participant.
  4. On the confirmation page, click Amount.
  5. Change the amount and save it.
  6. Click on the back button twice to return to Manual page.

Expected Result:

The new amount is preserved in Manual page

Actual Result:

The new amount is not preserved in Manual page

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

Bug6313586_1702585393338.20231214_195558.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0100d59ba09cfb0bc4
  • Upwork Job ID: 1735420492994256896
  • Last Price Increase: 2024-01-04
  • Automatic offers:
    • situchan | Reviewer | 28088789
    • mkhutornyi | Contributor | 28088790
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 14, 2023
@melvin-bot melvin-bot bot changed the title IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page [$500] IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page Dec 14, 2023
Copy link

melvin-bot bot commented Dec 14, 2023

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

Copy link

melvin-bot bot commented Dec 14, 2023

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

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

melvin-bot bot commented Dec 14, 2023

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

Copy link

melvin-bot bot commented Dec 14, 2023

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

@neonbhai
Copy link
Contributor

neonbhai commented Dec 14, 2023

Proposal

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

Amount is not preserved in Manual page when the amount is changed in confirmation page

What is the root cause of that problem?

This happens as on the MoneyRequestAmountForm the amount is calculated from selectedAmountAsString variable

const selectedAmountAsString = amount ? CurrencyUtils.convertToFrontendAmount(amount).toString() : '';
const [currentAmount, setCurrentAmount] = useState(selectedAmountAsString);

When we navigate back to this page, the selectedAmountAsString variable changes, but since the screen was already mounted, the state currentAmount still has the old amount, which is reflected on the page.

Video: This can be clearly seen when we log both variables
7ea2240d-791e-4975-87b4-db5e678ac0a8.mp4

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

We should add a useEffect that updates the current amount when selectedAmountAsString changes.

     useEffect(() => { 
        setCurrentAmount(selectedAmountAsString);
    }, [selectedAmountAsString, setCurrentAmount]);

Result

c5846578-4c56-468a-adcd-5fb359be318b.mp4

@Krishna2323
Copy link
Contributor

Can't reproduce on latest main branch.

@mkhutornyi
Copy link
Contributor

Proposal

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

IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page

What is the root cause of that problem?

We have logic of updating amount but only when tab is changed:

useEffect(() => {
if (!currency || !_.isNumber(amount)) {
return;
}
initializeAmount(amount);
// we want to re-initialize the state only when the selected tab changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedTab]);

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

add amount to dependency


This also fixes #33123 which has the same root cause:
Amount is cleared here

// Clear out the temporary money request if the reportID in the URL has changed from the transaction's reportID
useEffect(() => {
if (transaction.reportID === reportID) {
return;
}
IOU.startMoneyRequest_temporaryForRefactor(reportID, isFromGlobalCreate, transactionRequestType.current);

But not updated because of useEffect without amount dependency

@neonbhai
Copy link
Contributor

Proposal

Updated

@tienifr
Copy link
Contributor

tienifr commented Dec 15, 2023

Proposal

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

The new amount is not preserved in Manual page

What is the root cause of that problem?

We use currentAmount to show in the AmountPage.

It's just updated to amount from Onyx.IOU (that will be updated though the App) at the first time AmountPage is mounted

const selectedAmountAsString = amount ? CurrencyUtils.convertToFrontendAmount(amount).toString() : '';
const [currentAmount, setCurrentAmount] = useState(selectedAmountAsString);

When users go to other pages, this component is still in the stack that why currentAmount is not updated.

We have the logic to update currentAmount in setNewAmount. But we just call it when users type amount manually. So if users change amount from other page, this amount is not updated.

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

We should create the useEffect to update currentAmount when iou.amount get changed

    useEffect(()=>{
        setNewAmount(selectedAmountAsString);
    },[selectedAmountAsString])

We need to use setNewAmount(selectedAmountAsString) instead of setCurrentAmount(selectedAmountAsString) because in setNewAmount function we do not only update currentAmount but also selection

What alternative solutions did you explore? (Optional)

NA

@yh-0218
Copy link
Contributor

yh-0218 commented Dec 15, 2023

Proposal

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

The new amount is not preserved in Manual page

What is the root cause of that problem?

we didn't set setNewAmount when changed amount.

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


We need to replace selectedTab to amount to avoid several calculate.

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Dec 18, 2023

@garrettmknight, @situchan 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 Dec 18, 2023
Copy link

melvin-bot bot commented Dec 18, 2023

@garrettmknight, @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!

@situchan
Copy link
Contributor

reviewing proposals

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Dec 18, 2023
@garrettmknight
Copy link
Contributor

@situchan any proposals look good?

@melvin-bot melvin-bot bot removed the Overdue label Dec 21, 2023
Copy link

melvin-bot bot commented Dec 21, 2023

📣 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 Dec 25, 2023
Copy link

melvin-bot bot commented Dec 26, 2023

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

@garrettmknight
Copy link
Contributor

@situchan Can you review the proposals when you get a chance?

@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 2024
@luacmartins
Copy link
Contributor

Back from ooo. We can add amount back to the dependency array, but we should make sure that the amount is reset when we change tabs

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

melvin-bot bot commented Jan 8, 2024

📣 @situchan 🎉 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 Jan 8, 2024

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

@garrettmknight
Copy link
Contributor

@situchan can you give the PR a review when you get a chance?

@situchan
Copy link
Contributor

sorry not sure why this was not in my list. reviewing in an hour

@situchan
Copy link
Contributor

review complete

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 29, 2024
@melvin-bot melvin-bot bot changed the title [$500] IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page [HOLD for payment 2024-02-05] [$500] IOU - Amount is not preserved in Manual page when the amount is changed in confirmation page Jan 29, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 29, 2024
Copy link

melvin-bot bot commented Jan 29, 2024

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

Copy link

melvin-bot bot commented Jan 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.32-5 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-02-05. 🎊

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

Copy link

melvin-bot bot commented Jan 29, 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:

  • [@situchan] The PR that introduced the bug has been identified. Link to the PR:
  • [@situchan] 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:
  • [@situchan] 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:
  • [@situchan] Determine if we should create a regression test for this bug.
  • [@situchan] 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.
  • [@garrettmknight] 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 Feb 5, 2024
@garrettmknight garrettmknight added Weekly KSv2 and removed Daily KSv2 labels Feb 5, 2024
@garrettmknight
Copy link
Contributor

Paid - dropping to weekly for @situchan to finish the checklist.

@situchan
Copy link
Contributor

situchan commented Feb 5, 2024

  • The PR that introduced the bug has been identified. Link to the PR: Fix amount reset #32884
  • 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/32884/files#r1438338790
  • 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. We can skip regression test as caught by QA team
  • 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.

@garrettmknight
Copy link
Contributor

Done

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

No branches or pull requests

9 participants