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] Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page #56643

Closed
2 of 8 tasks
IuliiaHerets opened this issue Feb 11, 2025 · 15 comments
Closed
2 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Feb 11, 2025

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.0.96-0
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
Email or phone of affected tester (no customers): applausetester+4508qpo@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Rules are enabled in Workspace settings > More features page.
  1. Go to staging.new.expensify.com
  2. Go to Workspace settings > Rules.
  3. Click on the empty area next to "Prevent self-approvals" toggle button.
  4. Click on the empty area next to "Auto-pay approved reports" toggle button.

Expected Result:

The empty area next to "Prevent self-approvals" and "Auto-pay approved reports" toggle button is not clickable.

Actual Result:

The empty area next to "Prevent self-approvals" and "Auto-pay approved reports" toggle button is clickable and opens not here page.

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/7fcd0db1-dd10-4e23-8eb8-9a0e820e7347
Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021889343459881874746
  • Upwork Job ID: 1889343459881874746
  • Last Price Increase: 2025-02-18
Issue OwnerCurrent Issue Owner: @lschurr
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 11, 2025
Copy link

melvin-bot bot commented Feb 11, 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.

@etCoderDysto
Copy link
Contributor

Proposal

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

Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page

What is the root cause of that problem?

We are passing an array of menus to subMenuItems even though the feature is not enabled and, and the menu items are rendered with 0 opacity. Then when we click the empty space, we click the menu items and modal will be opened.

subMenuItems: [
<OfflineWithFeedback
pendingAction={!policy?.pendingFields?.shouldShowAutoApprovalOptions && policy?.autoApproval?.pendingFields?.limit ? policy?.autoApproval?.pendingFields?.limit : null}

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

We should pass the submenu items if the the feature is available. We should make similar change for all items that has subMenuItems

subMenuItems: workflowApprovalsUnavailable && [
                <OfflineWithFeedback

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

UI bug

What alternative solutions did you explore? (Optional)

@nkdengineer
Copy link
Contributor

Proposal

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

The empty area next to "Prevent self-approvals" and "Auto-pay approved reports" toggle button is clickable and opens not here page.

What is the root cause of that problem?

It starts happens from here,

https://github.com/Expensify/App/pull/55478/files#diff-392fa9016a94ecf52ff66b5e622264592a862f7c75ee9d537a8114d049c83d78L181

We always show the submenu items then it is hidden behind when isActive is false. So when we click on empty area next to Prevent self-approvals, it opens the name rules page and it display not found page because custom name rules is not enabled

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

We should only render the subMenuItems if isActive is true

<Accordion
    isExpanded={isExpanded}
    style={accordionStyle}
    isToggleTriggered={isToggleTriggered}
>
    {isActive && subMenuItems}
</Accordion>

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)

NA

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.

@drminh2807
Copy link
Contributor

drminh2807 commented Feb 11, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-02-11 09:26:52 UTC.

Proposal

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

Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page

What is the root cause of that problem?

The Accordion is still clickable when it is collapsed

<Animated.View style={[animatedStyle, style]}>
<View
onLayout={(e) => {
height.set(e.nativeEvent.layout.height);
}}
>
{children}
</View>
</Animated.View>

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

Disable clickable when Accordion is collapsed

  1. Pass isActive: boolean instead isExpanded: SharedValue<boolean>
  2. Use isActive to control pointerEvents
function Accordion({isActive, children, duration = 300, isToggleTriggered, style}: AccordionProps) {
    const isExpanded = useSharedValue(isActive);
    useEffect(() => {
        isExpanded.set(isActive);
    }, [isExpanded, isActive]);
.
.
.
            <View
                pointerEvents={isActive ? 'auto' : 'none'}
                onLayout={(e) => {
                    height.set(e.nativeEvent.layout.height);
                }}
            >
                {children}
            </View>

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)

N/A

@Krishna2323
Copy link
Contributor

Proposal

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

Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page

What is the root cause of that problem?

  • The Animated.View renders the children and even when it's collapsed, it has some part of the view clickable that leads to the bug.
    return (
    <Animated.View style={[animatedStyle, style]}>
    <View
    onLayout={(e) => {
    height.set(e.nativeEvent.layout.height);
    }}
    >
    {children}
    </View>
    </Animated.View>
    );
    }

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

  • We should make sure that when the Animated.View is not expanded, it does not capture any click events. So for fixing this issue, we need to add pointerEvents: 'none' when !isExpanded.get() is true.
    const animatedStyle = useAnimatedStyle(() => {
        if (!isToggleTriggered.get() && !isExpanded.get()) {
            return {
                height: 0,
                opacity: 0,
                pointerEvents: 'none',
            };
        }

        return {
            height: !isToggleTriggered.get() ? undefined : derivedHeight.get(),
            opacity: derivedOpacity.get(),
            pointerEvents: !isExpanded.get() ? 'none' : 'auto',
        };
    });

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

NA

What alternative solutions did you explore? (Optional)

@lschurr lschurr added the External Added to denote the issue can be worked on by a contributor label Feb 11, 2025
Copy link

melvin-bot bot commented Feb 11, 2025

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

@melvin-bot melvin-bot bot changed the title Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page [$250] Rules - Empty area next to "Prevent self-approvals" toggle button opens not here page Feb 11, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 11, 2025
Copy link

melvin-bot bot commented Feb 11, 2025

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

@bernhardoj
Copy link
Contributor

Proposal

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

There are clickable areas next to Prevent self-approvals which opens a not found page.

What is the root cause of that problem?

The rules are rendered using ToggleSettingsOptionRow which renders the sub menu items inside Accordion.

<Accordion
isExpanded={isExpanded}
style={accordionStyle}
isToggleTriggered={isToggleTriggered}
>
{subMenuItems}
</Accordion>

In Accordion component, we animate the expand/shrink of the sub menu by controlling the height and opacity style.

return (
<Animated.View style={[animatedStyle, style]}>
<View
onLayout={(e) => {
height.set(e.nativeEvent.layout.height);
}}
>
{children}
</View>
</Animated.View>
);

However, the sub menu item is never unmounted, it's still rendered with 0 height and opacity. In our case, the sub menu item of the "Custom report names" rule is clickable.

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

We have 2 options. First, the simplest one is to apply a overflow: hidden style to the Accordion.

This is how it will looks (a bit different from the current one)

web.mp4

OR

Don't render anything when the height is 0. The visible initial value will be from isExpanded value. Every time isExpanded is updated to true, we set the visible state to true.

const [isVisible, setIsVisible] = useState(isExpanded.get());

useAnimatedReaction(() => isExpanded.get(), (expanded) => {
    if (expanded) {
        setIsVisible(true);
    }
});

When the animation to height of 0 is completed, we set the visible state to false.

return withTiming(height.get() * Number(isExpanded.get()), {
duration,
easing: Easing.inOut(Easing.quad),
});

const newHeight = height.get() * Number(isExpanded.get());
return withTiming(newHeight, {
    duration,
    easing: Easing.inOut(Easing.quad),
}, (finished) => {
    if (finished && newHeight === 0) {
        setIsVisible(false)
    }
});

...

if (!isVisible) {
    return null;
}

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

N/A

Copy link

melvin-bot bot commented Feb 17, 2025

@akinwale, @lschurr Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Feb 17, 2025
@akinwale
Copy link
Contributor

Upon reviewing the proposals, it makes sense to avoid rendering elements that are not supposed to be visible nor interacted with, so we can move forward with @nkdengineer's proposal here.

🎀👀🎀 C+ reviewed.

Copy link

melvin-bot bot commented Feb 18, 2025

Triggered auto assignment to @neil-marcellini, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Feb 18, 2025

@akinwale not rendering the elements will break the animation, could you please check again?

Copy link

melvin-bot bot commented Feb 18, 2025

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

@neil-marcellini
Copy link
Contributor

I'm no longer able to reproduce the issue. I think it's already been solved.

@lschurr I'll leave it to you to handle any payment if needed (probably not needed right?) and close this out.

2025-02-19_10-40-45.mp4

@neil-marcellini neil-marcellini removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 19, 2025
@lschurr
Copy link
Contributor

lschurr commented Feb 19, 2025

Yep, looks like this is fixed. Closing!

@lschurr lschurr closed this as completed Feb 19, 2025
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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants