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

[$500] [HOLD for payment 2023-09-06] Dev - Unable to select a state #25998

Closed
6 tasks done
kavimuru opened this issue Aug 26, 2023 · 38 comments
Closed
6 tasks done

[$500] [HOLD for payment 2023-09-06] Dev - Unable to select a state #25998

kavimuru opened this issue Aug 26, 2023 · 38 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 Help Wanted Apply this label when an issue is open to proposals by contributors Needs Reproduction Reproducible steps needed

Comments

@kavimuru
Copy link

kavimuru commented Aug 26, 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. Open App ->Settings -> Workspace -> bank Account
  2. Enter the required details and proceed to step 2.
  3. Attempt to select your state.

Expected Result:

The user is able to select a state.

Actual Result:

The user cannot select a state.

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:
Reproducible in staging?: dev
Reproducible in production?: dev
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

Screen.Recording.2023-08-26.at.7.07.10.PM.mov

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017b84ce7e9fc17d03
  • Upwork Job ID: 1701792992094031872
  • Last Price Increase: 2023-09-13
@kavimuru kavimuru added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Needs Reproduction Reproducible steps needed Bug Something is broken. Auto assigns a BugZero manager. labels Aug 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 26, 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

@OSBotify
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.

@melvin-bot
Copy link

melvin-bot bot commented Aug 26, 2023

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

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 26, 2023

Proposal

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

On typing any char for statepicker the modal gets hide

What is the root cause of that problem?

Seems regression from #25672 where we migrate the BaseModal class component to the function component. Currently, it is doing the cleanup on the dependency changes which should occur on unmounting.

return () => {
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
if (isVisible) {
hideModal(true);
Modal.willAlertModalBecomeVisible(false);
}
// To prevent closing any modal already unmounted when this modal still remains as visible state
Modal.setCloseModal(null);
};
}, [hideModal, isVisible, onClose]);

https://github.com/Expensify/App/pull/25672/files#diff-a766f362da94923822313f0249c8cfaedf93151a08220f529255c40fc67bbf55L54-L63

Reason: Whenever user types in the state textinput, StatePicker will gets rerender and it creates new ref to the hidePickerModal as we haven't used useCallback for it. With this, useEffect dep change triggers and it will call the clean up function which will hide the modal.

Same can be reproducible for CountryPicker in Profile -> Home Address.

const hidePickerModal = () => {

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

I think we need to add a new useEffect without any dependency and move this clean up there which acts like a componentWillUnmount.

     useEffect(() => {
        return () => {
            // Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
            if (isVisible) {
                hideModal(true);
                Modal.willAlertModalBecomeVisible(false);
            }

            // To prevent closing any modal already unmounted when this modal still remains as visible state
            Modal.setCloseModal(null);
        };
    }, []);
  • Considering the other issue https://expensify.slack.com/archives/C049HHMV9SM/p1693115903343099 or similar issues where subsequent modal isn't opening, we need to add dependency onModalHide here as the function needs to update the ref when onModalHide updates, otherwise it calls the old onModalHide function and create issues. Bcoz for ThreeDotsMenu and FloatingActionButtonAndPopover we don't use shouldSetModalVisibility which won't recreate the func hideModal in BaseModal component.

onModalHide();
}
Modal.onModalDidClose();
if (!fullscreen) {
ComposerFocusManager.setReadyToFocus();
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps -- adding onModalHide to the dependency array causes too many unnecessary rerenders
[shouldSetModalVisibility],

[shouldSetModalVisibility, onModalHide]

Result
Screen.Recording.2023-08-27.at.01.27.50.mov

@melvin-bot melvin-bot bot added Daily KSv2 and removed Hourly KSv2 labels Aug 26, 2023
@hungvu193
Copy link
Contributor

Proposal

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

Dev - Unable to select a state

What is the root cause of that problem?

Problem came from the cleanup function of this effect:

useEffect(() => {
Modal.willAlertModalBecomeVisible(isVisible);
// To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu
Modal.setCloseModal(isVisible ? onClose : null);
return () => {
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
if (isVisible) {
hideModal(true);
Modal.willAlertModalBecomeVisible(false);
}
// To prevent closing any modal already unmounted when this modal still remains as visible state
Modal.setCloseModal(null);
};
}, [hideModal, isVisible, onClose]);

If we take a look at the log, we can see the cleanup function run everytime we type something, the problem is our onClose function is re-created everytime the component re-render. According the react docs:
React performs the cleanup when the component unmounts. However, as we learned earlier, effects run for every render and not just once. This is why React also cleans up effects from the previous render before running the effects next time.

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

Solution 1:
Add a new useEffect with only isVisible as dependency for cleanup:

    useEffect(() => {
        return () => {
            // Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
            if (isVisible) {
                hideModal(true);
                Modal.willAlertModalBecomeVisible(false);
            }
            // To prevent closing any modal already unmounted when this modal still remains as visible state
            Modal.setCloseModal(null);
        };
    }, [isVisible]);

Solution 2:
Every time we passed onClose to our modal, we should wrapped it with useCallBack.
For example in this case that hidePickerModal function.

What alternative solutions did you explore? (Optional)

N/A

@b4s36t4
Copy link
Contributor

b4s36t4 commented Aug 26, 2023

Proposal

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

Dev - Unable to select a state

What is the root cause of that problem?

This might be a regression from this PR #21049.

The component hierarchy is in this way AddressPage -> CountryPicker -> CountrySelectorModal

If we type anything in the CountrySelectorModal that update will be passed all the way to CountryPicker because of the state we have here

const [searchValue, setSearchValue] = useState(lodashGet(allCountries, value, ''));
.

After the state update tree render would be like this CountryPicker -> CountrySelectorModal

which means all the state in CountrySelectorModal will be wiped off(obsolete and causes re-render as stated in the above proposals) and component Modal get's re-rendered.

Which triggers this

return () => {
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
if (isVisible) {
hideModal(true);
Modal.willAlertModalBecomeVisible(false);
}
// To prevent closing any modal already unmounted when this modal still remains as visible state
Modal.setCloseModal(null);
};
that calls the onModalHide.

Kapture.2023-08-27.at.01.03.32.mp4

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

This happens with both CountrySelectorModal and StateSelectorModal because both of them following same kind of principles.

Input is related to the Modal's component, handling the state outside of modal is certainly causing the
re-renders which is leading to close the modal

I think we need to move the state here

const [searchValue, setSearchValue] = useState(lodashGet(allCountries, value, ''));
and here
const [searchValue, setSearchValue] = useState(lodashGet(allStates, `${value}.stateName`, ''));
should be moved to individual modal components so that component state is isolated and won't cause any re-renders.

Even this approach is also causing the whole component re-render(only state update) but it's only causing re-render for CountrySelectorModal which doesn't wipe the props which makes doesn't trigger this snippet here

return () => {
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
if (isVisible) {
hideModal(true);
Modal.willAlertModalBecomeVisible(false);
}
// To prevent closing any modal already unmounted when this modal still remains as visible state
Modal.setCloseModal(null);
};

What alternative solutions did you explore? (Optional)

NA

Result

Kapture.2023-08-27.at.01.09.21.mp4

@parasharrajat
Copy link
Member

parasharrajat commented Aug 27, 2023

Yes, it seems like an regression from #25672. Unless we hear from the author, we can move ahead with solving this issue here. Due to the weekend, it is fine to wait till Monday.

@hayata-suenaga
Copy link
Contributor

sorry people for a lot of assignment and unassignments, but because is a deploy blocker and it's causing issues with other PRs that involve pop over behavior, I gonna handle this 🙇

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 27, 2023

Ok, let me know in case my proposal makes sense and if I can do some help here.

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

@Pujan92, @kevinksullivan, @allroundexperts, @hayata-suenaga Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

@Pujan92, @kevinksullivan, @allroundexperts, @hayata-suenaga Eep! 4 days overdue now. Issues have feelings too...

@kevinksullivan kevinksullivan added the External Added to denote the issue can be worked on by a contributor label Sep 13, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-09-06] Dev - Unable to select a state [$500] [HOLD for payment 2023-09-06] Dev - Unable to select a state Sep 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

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

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

melvin-bot bot commented Sep 13, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

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

@kevinksullivan
Copy link
Contributor

Adding label to get upwork job created, not sure why that was skipped before.

@melvin-bot melvin-bot bot removed the Overdue label Sep 13, 2023
@kevinksullivan
Copy link
Contributor

Offers sent to @Pujan92 @Nodebrute and @allroundexperts . Let me know when you accept!

@Pujan92
Copy link
Contributor

Pujan92 commented Sep 13, 2023

Accepted @kevinksullivan, Just to confirm this needs to be paid using the earlier payment price, right?

@kevinksullivan
Copy link
Contributor

Can you elaborate on that @Pujan92 ? what is the earlier payment price?

@Pujan92
Copy link
Contributor

Pujan92 commented Sep 14, 2023

what is the earlier payment price?

@kevinksullivan I am referencing this as this issue seems created before 30th aug.

@kevinksullivan
Copy link
Contributor

kevinksullivan commented Sep 15, 2023

Payment summary:

@allroundexperts
Copy link
Contributor

Is there any speed bonus here @kevinksullivan?

@allroundexperts
Copy link
Contributor

Checklist

  1. This is a regression from rewrite BaseModal to a functional component #25672. The authors know this already and we stepped in to fix this earlier than they could.
  2. I don't think a Slack discussion is necessary here. Better testing would have caught this in PR review stage.
  3. A regression test would be helpful here. The steps mentioned in the issue description look good enough to me.

@allroundexperts
Copy link
Contributor

Bump of #25998 (comment) @kevinksullivan!

@melvin-bot melvin-bot bot added the Overdue label Sep 20, 2023
@kevinksullivan
Copy link
Contributor

Sorry @allroundexperts I missed that. Updated payment amounts

@melvin-bot melvin-bot bot removed the Overdue label Sep 21, 2023
@kevinksullivan
Copy link
Contributor

Updated payment to @Pujan92 , just need to pay out @allroundexperts

@hayata-suenaga
Copy link
Contributor

@allroundexperts could you accept the offer?

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@kevinksullivan
Copy link
Contributor

Asking @JmillsExpensify in DM about the newdot payment.

@JmillsExpensify
Copy link

$1,500 payment approved for @allroundexperts based on BZ summary.

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 Help Wanted Apply this label when an issue is open to proposals by contributors Needs Reproduction Reproducible steps needed
Projects
None yet
Development

No branches or pull requests