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 2023-11-02] [$2000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb #23300

Closed
2 of 6 tasks
kavimuru opened this issue Jul 20, 2023 · 127 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Jul 20, 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!


Action Performed:

  1. Click FAB on Chrome mobile
  2. Click Reqeust Money/ Split Bill
  3. Enter amount more than 3 digits (e.g 6323)
  4. Hold the back key "<"

Expected Result:

Last digit is removed and cursor is still at last place like Android app

Actual Result:

Last digit is removed but cursor is in front of last character

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.43-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

videoplayback.mp4
az_recorder_20230720_150324.1.mp4

Expensify/Expensify Issue URL:
Issue reported by: @ygshbht
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1689740152146159

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0186b5465f1e6964a7
  • Upwork Job ID: 1684547845836894208
  • Last Price Increase: 2023-10-13
  • Automatic offers:
    • abdulrahuman5196 | Reviewer | 27293534
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 20, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 20, 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

@kavimuru
Copy link
Author

Proposal

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

Inconsistent cursor behavior when a user long-presses the back button on the 'Split Bill/Request Money' page between Android app and mobile web.

What is the root cause of that problem?

React's state management involves batching state updates for performance optimization, and in the current implementation, the setSelection function in setNewAmount (MoneyRequestAmountPage component) function seems to be getting called more than once. This leads to unpredictable cursor behavior due to the asynchronous nature of state updates in React.

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

The solution focuses on preventing multiple invocations of setSelection within setAmount. We introduce a flag hasSelectionBeenSet that allows setSelection to be called only once, thereby aligning cursor behavior across different platforms.
Original code block:

const setNewAmount = (newAmount) => {
    const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount);
    if (!validateAmount(newAmountWithoutSpaces)) {
        setAmount((prevAmount) => prevAmount);
        setSelection((prevSelection) => ({...prevSelection}));
        return;
    }
    setAmount((prevAmount) => {
        setSelection((prevSelection) => getNewSelection(prevSelection, prevAmount.length, newAmountWithoutSpaces.length));
        return stripCommaFromAmount(newAmountWithoutSpaces);
    });
};

Modified code block:

const setNewAmount = (newAmount) => {
    const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount);
    if (!validateAmount(newAmountWithoutSpaces)) {
        setAmount((prevAmount) => prevAmount);
        setSelection((prevSelection) => ({...prevSelection}));
        return;
    }
    let hasSelectionBeenSet = false;
    setAmount((prevAmount) => {
        if (!hasSelectionBeenSet) {
            setSelection((prevSelection) => {
                hasSelectionBeenSet = true;
                return getNewSelection(prevSelection, prevAmount.length, newAmountWithoutSpaces.length);
            });
        }
        return stripCommaFromAmount(newAmountWithoutSpaces);
    });
};

@ygshbht
Copy link
Contributor

ygshbht commented Jul 20, 2023

Thanks Kavi.


To add more details

const setNewAmount = (newAmount) => {
// Remove spaces from the newAmount value because Safari on iOS adds spaces when pasting a copied value
// More info: https://github.com/Expensify/App/issues/16974
const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount);
// Use a shallow copy of selection to trigger setSelection
// More info: https://github.com/Expensify/App/issues/16385
if (!validateAmount(newAmountWithoutSpaces)) {
setAmount((prevAmount) => prevAmount);
setSelection((prevSelection) => ({...prevSelection}));
return;
}
setAmount((prevAmount) => {
setSelection((prevSelection) => getNewSelection(prevSelection, prevAmount.length, newAmountWithoutSpaces.length));
return stripCommaFromAmount(newAmountWithoutSpaces);
});
};

What alternative solutions did you explore? (Optional)

A bit more complex solution involves moving setSelection out of setAmount and doing some restructuring to acheive the same result

Working solution:

XRecorder_19072023_083315.mp4

Regarding the alternate solution:

You could also club amount and selection in one state variable as they are almost always updated together
So the new modification instead of this

let hasSelectionBeenSet = false;
setAmount((prevAmount) => {
    if (!hasSelectionBeenSet) {
        setSelection((prevSelection) => {
            hasSelectionBeenSet = true;
            return getNewSelection(prevSelection, prevAmount.length, newAmountWithoutSpaces.length);
        });
    }
    return stripCommaFromAmount(newAmountWithoutSpaces);
});

can be:

setAmountAndSelection(({amount, selection})=>{
    return { amount:stripCommaFromAmount(newAmountWithoutSpaces),
        selection: getNewSelection(selection, amount.length, newAmountWithoutSpaces.length)
    }
})

@ygshbht

This comment was marked as duplicate.

@melvin-bot melvin-bot bot added the Overdue label Jul 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

@michaelhaxhiu Eep! 4 days overdue now. Issues have feelings too...

@michaelhaxhiu michaelhaxhiu added the External Added to denote the issue can be worked on by a contributor label Jul 27, 2023
@melvin-bot melvin-bot bot changed the title IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb [$1000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb Jul 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 27, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0186b5465f1e6964a7

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

melvin-bot bot commented Jul 27, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 27, 2023

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

@michaelhaxhiu
Copy link
Contributor

Passing to External

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 27, 2023
@abdulrahuman5196
Copy link
Contributor

Reviewing today

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 31, 2023
@michaelhaxhiu
Copy link
Contributor

How's review coming @abdulrahuman5196 🐰 ?

@melvin-bot melvin-bot bot removed the Overdue label Aug 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@abdulrahuman5196
Copy link
Contributor

Will check in my morning. Was working on WAQ crossed issues and deploy blockers.

@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

@michaelhaxhiu @abdulrahuman5196 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!

@michaelhaxhiu michaelhaxhiu changed the title [$1000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb [$2000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb Aug 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

Upwork job price has been updated to $2000

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Oct 20, 2023
@ygshbht
Copy link
Contributor

ygshbht commented Oct 20, 2023

@abdulrahuman5196 The PR is ready for review

@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @ygshbht got assigned: 2023-10-20 11:53:51 Z
  • when the PR got merged: 2023-10-25 14:14:42 UTC
  • days elapsed: 3

On to the next one 🚀

@ygshbht
Copy link
Contributor

ygshbht commented Oct 25, 2023

@laurenreidexpensify @madmax330 Will the job be eligible for bonus? PR was created within hours of assignment and C+ approved the changes within 2 days. The wait was for @madmax330 to approve. Thanks!

@abdulrahuman5196
Copy link
Contributor

Will the job be eligible for bonus? PR was created within hours of assignment and C+ approved the changes within 2 days.

This would be yes similar to other issues IMO.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 26, 2023
@melvin-bot melvin-bot bot changed the title [$2000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb [HOLD for payment 2023-11-02] [$2000] IOU : Inconsistent behavior when long pressing the back button in Android app vs mWeb Oct 26, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

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.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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:

  • [@abdulrahuman5196] The PR that introduced the bug has been identified. Link to the PR:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] Determine if we should create a regression test for this bug.
  • [@abdulrahuman5196] 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.
  • [@laurenreidexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@abdulrahuman5196
Copy link
Contributor

The PR that introduced the bug has been identified. Link to the PR:
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:
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:

Not a regression. Seems to be the behaviour for long time.

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.

  1. Click FAB on Chrome mobile
  2. Click Reqeust Money/ Split Bill
  3. Enter amount more than 3 digits (e.g 6323)
  4. Hold the back key "<"
  5. Verify that last digit is removed and cursor is still at last place

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 2, 2023
@laurenreidexpensify
Copy link
Contributor

Payment Summary:

  • External issue reporter @ygshbht $250 - please apply to job in Upwork
  • Contributor that fixed the issue @ygshbht $2000 + $1000 bonus - please apply to job in Upwork
  • Contributor+ that helped on the issue and/or PR @abdulrahuman5196 - $2000 + $1000 bonus - payment issued in Upwork

@laurenreidexpensify laurenreidexpensify added External Added to denote the issue can be worked on by a contributor and removed External Added to denote the issue can be worked on by a contributor labels Nov 3, 2023
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 3, 2023
@laurenreidexpensify laurenreidexpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Help Wanted Apply this label when an issue is open to proposals by contributors Bug Something is broken. Auto assigns a BugZero manager. labels Nov 3, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Nov 3, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Nov 3, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Nov 3, 2023
@laurenreidexpensify
Copy link
Contributor

@ygshbht please accept job in Upwork - https://www.upwork.com/en-gb/jobs/~0175ccda3750737e98

@ygshbht
Copy link
Contributor

ygshbht commented Nov 3, 2023

Thanks. Accepted!

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

No branches or pull requests

9 participants