Skip to content

[$250] Reports - Filter buttons are not responsive after paying invoice #65579

Closed

Description

@jponikarchuk

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: 9.1.77-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp https://expensify.testrail.io/index.php?/cases/view/4090175
Email or phone of affected tester (no customers): sndoijsddinsjo@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Search

Action Performed:

Precondition:

  • User has received an invoice.
  • The invoice receiver will perform the following steps:
  1. Go to staging.expensify.com
  2. Go to Reports > Expenses.
  3. Click Type:Expense.
  4. Type list opens without issue.
  5. Go to Inbox.
  6. Open invoice room.
  7. Click Pay.
  8. Click Pay as an individual > Pay elsewhere.
  9. Go to Reports > Expenses.
  10. Click Type:Expense or other filter buttons (Status, Date, From).

Expected Result:

Type list will open without issue.

Actual Result:

Filter buttons are not responsive after paying invoice.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021944040694556444245
  • Upwork Job ID: 1944040694556444245
  • Last Price Increase: 2025-07-26
Issue OwnerCurrent Issue Owner: @NikkiWines

Activity

  1. added
    Daily
    Bug
    on Jul 7, 2025
  2. melvin-bot commented on Jul 7, 2025

    @melvin-bot

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

  3. Eskalifer1 commented on Jul 7, 2025

    @Eskalifer1
    Contributor

    Proposal

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

    Reports - Filter buttons are not responsive after paying invoice

    What is the root cause of that problem?

    The reason is this if:

    if (!previousValue && willAlertModalBecomeVisible) {
    return false;
    }

    The value of willAlertModalBecomeVisible is true, so we get into this if

    I suspect that when unmounting this button, the ONYXKEYS.MODAL value does not have time to change to false, which is why the value remains true

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

    When unmounting this button, we can add the willAlertModalBecomeVisible(false) function:

    function SettlementButton({

        useEffect(() => {
            return () => {
                willAlertModalBecomeVisible(false);
            };
        }, []);

    Alternatively, we can add this to the function when selecting this value

    onSelected: () => onPress(CONST.IOU.PAYMENT_TYPE.ELSEWHERE),

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

    None

    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.

  4. daledah commented on Jul 7, 2025

    @daledah
    Contributor

    Proposal

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

    Filter buttons are not responsive after paying invoice.

    What is the root cause of that problem?

    When pressing "Pay as individual" button, we don't set shouldCallAfterModalHide, so we call onSelected without closing the modal:

    } else {
    onItemSelected?.(selectedItem, index, event);
    selectedItem.onSelected?.();
    }

    In onSelected, we call startAnimation

    Which sets isPaidAnimationRunning as true

    const startAnimation = useCallback(() => {
    setIsPaidAnimationRunning(true);

    And sets isAnimationRunning here to true

    const isAnimationRunning = isPaidAnimationRunning || isApprovedAnimationRunning;

    This action causes SettlementButton to be forcefully unmounted, without closing the active modal first:

    {!isAnimationRunning && (
    <SettlementButton
    // eslint-disable-next-line react/jsx-props-no-spreading
    {...settlementButtonProps}
    wrapperStyle={wrapperStyle}
    isDisabled={isAnimationRunning || isDisabled}
    />
    )}

    So the logics here is not triggered properly

    useEffect(() => {
    let removeOnClose: () => void;
    if (isVisible) {
    onModalShow();
    onOpen?.({
    ref: withoutOverlayRef,
    close: onClose ?? NOOP,
    anchorRef,
    });
    removeOnClose = setCloseModal(onClose ?? NOOP);
    } else {
    onModalHide();
    close(anchorRef);
    onModalDidClose();
    }
    willAlertModalBecomeVisible(isVisible, true);
    return () => {
    if (!removeOnClose) {
    return;
    }
    removeOnClose();
    };
    // We want this effect to run strictly ONLY when isVisible prop changes
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [isVisible]);

    And willAlertModalBecomeVisible remains true. This will always prevent opening filter options:

    if (!previousValue && willAlertModalBecomeVisible) {

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

    We should force closing modal before calling onSelected function for SettlementButton

    Add shouldCallModalAfterHide: true to all subMenuItems here:

    subMenuItems: [

    and here:

    subMenuItems: [

    Note

    There has been a couple issues related to the DropdownButton component, so I suggest add an additional fix to that component as well

    The logic here

    if (!previousValue && willAlertModalBecomeVisible) {

    was added in #63996 to fix the issue where we can open 2 dropdown buttons at the same time. But it accidentally also affects behaviour if there's other modals. So we can limit the logic to only apply when DropdownButton is already rendered on screen.

    Add a previous value for willAlertModalBecomeVisible in DropdownButton

    const prevWillAlertModalBecomeVisible = usePrevious(willAlertModalBecomeVisible);

    Then update here

    if (!previousValue && willAlertModalBecomeVisible) {

    if (!previousValue && willAlertModalBecomeVisible && prevWillAlertModalBecomeVisible === false) {

    This way, when navigating from other pages, prevWillAlertModalBecomeVisible will be undefined and will not satisfy the condition above.

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

    None

    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.

  5. bernhardoj commented on Jul 8, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Filter buttons are not responsive after paying invoice.

    What is the root cause of that problem?

    When the payment option is visible, willAlertModalBecomeVisible becomes true, and the value is stuck at true.

    const toggleOverlay = useCallback(() => {
    setIsOverlayVisible((previousValue) => {
    if (!previousValue && willAlertModalBecomeVisible) {
    return false;
    }

    When we pay the invoice, the settlement button is immediately unmounted because isAnimationRunning is true.

    {isAnimationRunning && canShow && (
    <Animated.View
    ref={(el) => {
    viewRef.current = el as HTMLElement | null;
    }}
    exiting={buttonAnimation}
    >
    <Button
    text={isApprovedAnimationRunning ? translate('iou.approved') : translate('iou.paymentComplete')}
    success
    icon={icon}
    />
    </Animated.View>
    )}
    {!isAnimationRunning && (
    <SettlementButton
    // eslint-disable-next-line react/jsx-props-no-spreading
    {...settlementButtonProps}
    wrapperStyle={wrapperStyle}
    isDisabled={isAnimationRunning || isDisabled}
    />
    )}

    We already have a logic to handle the case when a modal is unmounted without being closed first by triggering the modal hide callback on unmount.

    useEffect(
    () => () => {
    // Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
    if (!isVisibleRef.current) {
    return;
    }
    hideModalCallbackRef.current?.(true);
    },
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    [],
    );

    const hideModal = useCallback(
    (callHideCallback = true) => {
    if (areAllModalsHidden()) {
    willAlertModalBecomeVisible(false);
    if (shouldSetModalVisibility && !Navigation.isTopmostRouteModalScreen()) {

    However, in this case, it uses a PopoverWithoutOverlay, which doesn't have that logic yet.

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

    Add the unmount logic to PopoverWithoutOverlay too.

    useEffect(
        () => () => {
            if (!isVisibleRef.current) {
                return;
            }
            willAlertModalBecomeVisible(false, true);
        }, [],
    );
    

    This is enough to fix our issue, but we can improve it further by:

    1. Move this into a function and then call it when unmount, just like in BaseModal.

      } else {
      onModalHide();
      close(anchorRef);
      onModalDidClose();
      }
      willAlertModalBecomeVisible(isVisible, true);

    2. Instead of using isVisibleRef, we can use shouldCallHideModalOnUnmount ref. We set shouldCallHideModalOnUnmount to true when the modal is visible,

      if (isVisible) {
      onModalShow();
      onOpen?.({

    and set it to false when the modal hides,

    } else {
    onModalHide();

    This is to avoid this kind of issue.

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

    N/A

  6. melvin-bot commented on Jul 11, 2025

    @melvin-bot

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

  7. added
    External
    on Jul 12, 2025
  8. changed the title [-]Reports - Filter buttons are not responsive after paying invoice[/-] [+][$250] Reports - Filter buttons are not responsive after paying invoice[/+] on Jul 12, 2025
  9. melvin-bot commented on Jul 12, 2025

    @melvin-bot
  10. added
    Help Wanted
    on Jul 12, 2025
  11. 19 remaining items

  12. sobitneupane commented on Jul 23, 2025

    @sobitneupane
    Contributor

    There is no need to use this props in our case. Instead of avoiding the real issue by applying the props one by one, we can have a global fix that fixes the root cause where the modal hide isn't called.

    @bernhardoj are you suggesting we don’t need shouldCallAfterModalHide at all in the codebase, or only that it’s unnecessary in this particular case?

  13. bernhardoj commented on Jul 23, 2025

    @bernhardoj
    Contributor

    We still need it in the codebase, but not in this case. shouldCallAfterModalHide is useful when we are going to open another modal from a modal. That's why we also have many Modal.close usage. One of the examples

    const delegatePopoverMenuItems: PopoverMenuItem[] = [
    {
    text: translate('delegate.changeAccessLevel'),
    icon: Expensicons.Pencil,
    onPress: () => {
    if (isActingAsDelegate) {
    modalClose(() => showDelegateNoAccessModal());
    return;
    }
    if (isAccountLocked) {
    modalClose(() => showLockedAccountModal());
    return;
    }

  14. sobitneupane commented on Jul 24, 2025

    @sobitneupane
    Contributor

    Thanks for the update @bernhardoj

    Yup, it makes sense. We're mostly using it with delete options, probably because it's followed by a delete confirmation modal.

    But I think it makes sense in our case too. The issue happens because we're unmounting the settlement button before the popover closes. shouldCallAfterModalHide would make sure the unmount happens only after the modal is closed. Wouldn't that be the right approach? Do you see any potential shortcomings with this?

  15. sobitneupane commented on Jul 24, 2025

    @sobitneupane
    Contributor

    Regarding the approach you suggested, we can add a cleanup on unmounting as well. I’m okay with it, but I believe it should only be used as a fallback in case the popover isn’t closed properly beforehand.

    I stumbled upon a weird issue while testing your solution—maybe I’m missing something:

    Screen.Recording.2025-07-24.at.18.23.05.mov
  16. bernhardoj commented on Jul 25, 2025

    @bernhardoj
    Contributor

    I can't repro the issue.

    shouldCallAfterModalHide would make sure the unmount happens only after the modal is closed. Wouldn't that be the right approach? Do you see any potential shortcomings with this?

    True, but at this point, we just need to decide which approach is better. Using shouldCallAfterModalHide means the action will be delayed because it waits for the modal to close. From the UX perspective, I think the immediate action is better.

    I'll leave the decision up to you and @NikkiWines

  17. melvin-bot commented on Jul 25, 2025

    @melvin-bot

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

  18. mvtglobally commented on Jul 26, 2025

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  19. melvin-bot commented on Jul 26, 2025

    @melvin-bot

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

  20. NikkiWines commented on Jul 28, 2025

    @NikkiWines
    Contributor

    I'm also unable to reproduce the issue on staging now - looks like maybe no action is needed here now 😅

    Screen.Recording.2025-07-28.at.12.28.59.mov
  21. izarutskaya commented on Jul 28, 2025

    @izarutskaya

    Not reproducible

    bandicam.2025-07-28.15-34-36-296.mp4
  22. bfitzexpensify commented on Jul 28, 2025

    @bfitzexpensify
    Contributor

    Ok, let's close this out then

  23. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions