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

[$250] Chat - Re-selection is required to change payment method from Pay elsewhere to Expensify #57381

Open
8 tasks done
IuliiaHerets opened this issue Feb 25, 2025 · 14 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. DeployBlockerCash This issue or pull request should block deployment Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Hourly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Feb 25, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.5-2
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5646450
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: MacOS 14.7.4 / Safari, Chrome, Desktop. iPhone 15 Pro / 18.3.1. Google Pixel 5 / Android 14
App Component: Money Requests

Action Performed:

  1. Open Expensify App or go to staging.new.expensify.com
  2. Login with any account
  3. Go to any chat or start new one
  4. Open "+" > Pay 'Username'
  5. Enter any amount and click "Next"
  6. Change payment method from "Pay Elsewhere" to "Pay with Expensify" and vice versa

Expected Result:

User need to select another method once to change the payment method

Actual Result:

User must repeat the selection to change the payment method

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

https://github.com/user-attachments/assets/3eb1de9f-9d16-4abf-87e5-0a263b713283
https://github.com/user-attachments/assets/6728379d-78bc-4b3f-9538-71ebb93965de

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021894380561474132011
  • Upwork Job ID: 1894380561474132011
  • Last Price Increase: 2025-02-25
Issue OwnerCurrent Issue Owner: @suneox
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. DeployBlockerCash This issue or pull request should block deployment labels Feb 25, 2025
Copy link

melvin-bot bot commented Feb 25, 2025

Triggered auto assignment to @Gonals (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Feb 25, 2025

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

Copy link

melvin-bot bot commented Feb 25, 2025

💬 A slack conversation has been started in #expensify-open-source

@melvin-bot melvin-bot bot added the Daily KSv2 label Feb 25, 2025
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Feb 25, 2025
Copy link
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.

@IuliiaHerets
Copy link
Author

Issue is not repro on production

bandicam.2025-02-25.08-28-59-151.mp4

@nkdengineer
Copy link
Contributor

Proposal

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

User must repeat the selection to change the payment method

What is the root cause of that problem?

When users select the different payment method, we will update the lastPaymentMethod, but we don't want to change the order so we don't include it in the dependencies, and

We need to be sure that onPress should be wrapped in an useCallback to prevent unnecessary updates.

return buttonOptions;
// We don't want to reorder the options when the preferred payment method changes while the button is still visible except for component initialization when the last payment method is not initialized yet.
// We need to be sure that onPress should be wrapped in an useCallback to prevent unnecessary updates.
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps

That means onPress should not be changed. We can see in the dependencies, we include setFormError, we get it from useDebouncedState

const [formError, debouncedFormError, setFormError] = useDebouncedState<TranslationPaths | ''>('');

but it's not wrapped inside useCallback

const handleSetValue = (newValue: T) => {

That makes onPress is updated, so the payment method order changes

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

Wrap handleSetValue inside useCallback

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@Gonals Gonals added the External Added to denote the issue can be worked on by a contributor label Feb 25, 2025
@melvin-bot melvin-bot bot changed the title Chat - Re-selection is required to change payment method from Pay elsewhere to Expensify [$250] Chat - Re-selection is required to change payment method from Pay elsewhere to Expensify Feb 25, 2025
Copy link

melvin-bot bot commented Feb 25, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 25, 2025
Copy link

melvin-bot bot commented Feb 25, 2025

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

@Gonals
Copy link
Contributor

Gonals commented Feb 25, 2025

@suneox, this is a blocker, so let's prioritize accordingly 👍

@suneox
Copy link
Contributor

suneox commented Feb 25, 2025

@suneox, this is a blocker, so let's prioritize accordingly 👍

Sure, I'll check this one within a few hours.

@suneox
Copy link
Contributor

suneox commented Feb 25, 2025

@nkdengineer Although your solution can resolve this issue, could you please provide more explanation about savePreferredPaymentMethod updating lastPaymentMethod in relation to the setFormError dependency? Since this issue doesn’t occur on the latest production.

Screen.Recording.2025-02-25.at.22.37.47.mp4

@nkdengineer
Copy link
Contributor

@suneox setFormError is not wrapped into useCallback so it’s updated whenever the parent re-renders or the props/state inside the component change. That means there’re many factors that cause the setFormError update.

I think the offending PR can be #56759, since the issue is not reproducible when I revert this PR

@suneox
Copy link
Contributor

suneox commented Feb 25, 2025

I think the offending PR can be #56759, since the issue is not reproducible when I revert this PR

@nkdengineer I agree that #56759 is the offending PR. It looks like the useProductTrainingContext hook causes a re-render for the MoneyRequestConfirmationList page.
The proposal from @nkdengineer to prevent updates to the onPress func by adjusting dependencies LGTM.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Feb 25, 2025

Current assignee @Gonals is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. DeployBlockerCash This issue or pull request should block deployment Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Hourly KSv2
Projects
None yet
Development

No branches or pull requests

5 participants