Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.49k stars 2.84k forks source link

[HOLD for payment 2023-08-01] [$1000] Web - App does not remove dot from amount in split bill after first try #22361

Closed kbecciv closed 1 year ago

kbecciv commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Click on + and click on split bill
  3. Enter any amount and write decimal dot (eg. 1234.)
  4. Click on next and select any users
  5. Click on back twice and observe that normally app removes the dot from the end of amount
  6. Again change the amount or keep the amount the same and write dot in the end.
  7. Again select any users or keep the already selected user and click on next
  8. Go back twice and observe that app no longer removes dot from the amount

Expected Result:

App should remove the dot from the amount if user has not inserted any digit after it.

Actual Result:

App does not removes the dot from the amount when we edit the amount second time even if no digit has been inserted after it.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Version Number: 1.3.37-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 Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/93399543/f220ef96-2558-4285-84cc-fef1a247ff95

https://github.com/Expensify/App/assets/93399543/57570bcb-223d-42b6-904c-b777d728fc87

Expensify/Expensify Issue URL: Issue reported by: @dhanashree-sawant Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1688631197920759

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01516b47bd364f3b33
  • Upwork Job ID: 1677044876093419520
  • Last Price Increase: 2023-07-06
melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

kushu7 commented 1 year ago

Proposal

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

App does not remove dot from amount in split bill after first try

What is the root cause of that problem?

https://github.com/Expensify/App/blob/d98a02a5d227c4503e3e3d05c7a3029431d51145/src/pages/iou/steps/MoneyRequestAmountPage.js#L150-L159 Problem is here when amount is same. we do not update amount state variable. it will work fine like if we keep changing amount like, 123. goto Next again go to amount page change amount 1234.. you will see it work as expected. as prevProps.iou.amount !== this.props.iou.amount this condition will become true.

but when we again add . to old amount, our condition will become false. and we can see . is still there.

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

Instead of relying on just iou amount changes. we should update state amount variable in navigateToNextPage function. this way our component will have formatted amount value.

https://github.com/Expensify/App/blob/d98a02a5d227c4503e3e3d05c7a3029431d51145/src/pages/iou/steps/MoneyRequestAmountPage.js#L401-L405

we can add this here on Line 404

this.setState((prevState)=>{
    const amountAsString = CurrencyUtils.convertToWholeUnit(prevState.selectedCurrencyCode, amountInSmallestCurrencyUnits).toString() || ''
    return {
        amount:amountAsString, 
        selection: { 
            start: amountAsString.length, 
            end: amountAsString.length, 
        }, 
    }
})
Video https://github.com/Expensify/App/assets/31707153/3fc3f989-04ed-488d-a059-1c96b7343832

What alternative solutions did you explore? (Optional)

None

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Current assignee @puneetlath is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] commented 1 year ago

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

getusha commented 1 year ago

Proposal

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

What is the root cause of that problem?

https://github.com/Expensify/App/blob/d98a02a5d227c4503e3e3d05c7a3029431d51145/src/pages/iou/steps/MoneyRequestAmountPage.js#L151-L151

the above code eventually will parse the amount to number and convert it to string, which will make sure the amount in string is correct, but when we do not change the value it won't be called, this will have a straightforward fix.

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

We should parse the amount to number and convert it to string, for example:

parseFloat("11.").toString() === "11"
parseFloat("11.1").toString() === "11.1"

inside navigateToNextPage we should add the following to make sure the value is parsed as the right number and converted to a string. that's the only thing convertToWholeUnit did to set the value without the .

this.setState({amount: parseFloat(this.state.amount).toString()})

We also have to set the selection state according to the updated amount.

https://github.com/Expensify/App/assets/75031127/c1fe14c8-a70e-4dd0-9b93-286b7577e927

What alternative solutions did you explore? (Optional)

manjesh-yadav commented 1 year ago

Proposal

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

App does not remove dot from amount in split bill after first try

What is the root cause of that problem?

https://github.com/Expensify/App/blob/d98a02a5d227c4503e3e3d05c7a3029431d51145/src/pages/iou/steps/MoneyRequestAmountPage.js#L150-L159

  1. We parse the amount to the number and convert it to a string
  2. when we add a dot again, the old amount and the new amount is the same after parsing, and our condition will become false the state is not updated and we can see the dot is still there

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

When we navigate to navigateToNextPage we should parse it again to convert into string and set the right cursor position


const amountAsString = Number(this.state.amount).toString()
this.setState({
                amount: amountAsString,
                selection: {
                    start: amountAsString.length,
                    end: amountAsString.length,
                },
            });```
getusha commented 1 year ago

@manjesh-yadav i proposed parsing and converting to string above

eVoloshchak commented 1 year ago

Reviewing proposals today

eVoloshchak commented 1 year ago

That is an interesting bug🧐 The proposals are quite similar, I think we should proceed with @kushu7's proposal since that was the first proposal to identify the root cause and propose a fix

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed! cc: @puneetlath

melvin-bot[bot] commented 1 year ago

πŸ“£ @eVoloshchak Please request via NewDot manual requests for the Reviewer role ($1000)

melvin-bot[bot] commented 1 year ago

πŸ“£ @eVoloshchak πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Upwork job

melvin-bot[bot] commented 1 year ago

πŸ“£ @kushu7 πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

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 πŸ“–

melvin-bot[bot] commented 1 year ago

πŸ“£ @dhanashree! πŸ“£ Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
melvin-bot[bot] commented 1 year ago

The BZ member will need to manually hire dhanashree for the Reporter role. Please store your Upwork details and apply to our Upwork job so this process is automatic in the future!

kushu7 commented 1 year ago

@eVoloshchak PR is ready for review.

cc @puneetlath

melvin-bot[bot] commented 1 year ago

@puneetlath, @eVoloshchak, @kushu7 Whoops! This issue is 2 days overdue. Let's get this updated quick!

eVoloshchak commented 1 year ago

@kbecciv, @puneetlath is OOO, is there a way we can reassign an engineer to review the PR? Or should we just put this on hold?

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.44-2 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-08-01. :confetti_ball:

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

melvin-bot[bot] commented 1 year ago

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:

puneetlath commented 1 year ago

@eVoloshchak friendly reminder about the checklist ahead of next week.

eVoloshchak commented 1 year ago
puneetlath commented 1 year ago

Issue reporter: @dhanashree-sawant $250 (paid via Upwork) Contributor: @kushu7 $1000 (paid via Upwork) Contributor+: @eVoloshchak $1500 (to be NewDot)

@eVoloshchak can you please request payment on NewDot and then comment here once you have? Thanks!

kushu7 commented 1 year ago

Contributor: @kushu7 $1000 (paid via Upwork)

Hello @puneetlath , It seems a speed bonus may be applicable here, as the pull request was ready to merge within 2 daysbut you were OOO. I also experienced a similar case in the past: https://github.com/Expensify/App/issues/20973#issuecomment-1626711336

puneetlath commented 1 year ago

Ah yes, right you are. I'll amend.

kushu7 commented 1 year ago

Ah yes, right you are. I'll amend.

@puneetlath I have accepted new offer on upwork. πŸ˜‡

eVoloshchak commented 1 year ago

@puneetlath, thanks, requested the payment via NewDotπŸŽ‰

JmillsExpensify commented 1 year ago

Reviewed details for @eVoloshchak. These details are accurate based on summary from Business Reviewer and are now approved for payment in NewDot.

puneetlath commented 1 year ago

Great, closing out. Thanks everyone!