Repository navigation
[Payment due @suneox] Fix isAttendeeTrackingEnabled default to true for Classic backwards compat #86818
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
[Payment due @suneox] Fix isAttendeeTrackingEnabled default to true for Classic backwards compat #86818
Changes from all commits
bb1e7a5
829f18e
9934d63
309909a
84075f5
986deed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ | |
|
|
||
| let allPolicies: OnyxCollection<Policy>; | ||
|
|
||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => (allPolicies = value), | ||
|
|
@@ -813,6 +813,14 @@ | |
| return policy?.type === CONST.POLICY.TYPE.CORPORATE; | ||
| } | ||
|
|
||
| /** | ||
| * For backwards compatibility with Expensify Classic, attendee tracking defaults to enabled | ||
| * on Control policies when the property is undefined. | ||
| */ | ||
| function isAttendeeTrackingEnabled(policy: OnyxEntry<Policy>): boolean { | ||
| return (isControlPolicy(policy) && policy?.isAttendeeTrackingEnabled) ?? true; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This change makes Classic control policies resolve Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| /** | ||
| * Whether the policy can access a feature based on plan level. | ||
| * Corporate-only features are restricted to control (Corporate) policies. | ||
|
|
@@ -1014,6 +1022,9 @@ | |
| if (featureName === CONST.POLICY.MORE_FEATURES.IS_TIME_TRACKING_ENABLED) { | ||
| return isTimeTrackingEnabled(policy); | ||
| } | ||
| if (featureName === CONST.POLICY.MORE_FEATURES.IS_ATTENDEE_TRACKING_ENABLED) { | ||
| return isAttendeeTrackingEnabled(policy); | ||
| } | ||
|
|
||
| return !!policy?.[featureName]; | ||
| } | ||
|
|
@@ -2161,6 +2172,7 @@ | |
| getApprovalWorkflow, | ||
| getReimburserAccountID, | ||
| isControlPolicy, | ||
| isAttendeeTrackingEnabled, | ||
| isCollectPolicy, | ||
| isNetSuiteCustomSegmentRecord, | ||
| getNameFromNetSuiteCustomField, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,7 +257,7 @@ describe('useAdvancedSearchFilters', () => { | |
|
|
||
| describe('attendee filter visibility', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MelvinBot let's add a test to confirm that we show the attendee filter when the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test that creates a Corporate policy without |
||
| it('hides attendee filter when no policies have attendee tracking enabled', async () => { | ||
| const policy = buildPolicy(1, {isAttendeeTrackingEnabled: false}); | ||
| const policy = buildPolicy(1, {type: CONST.POLICY.TYPE.CORPORATE, isAttendeeTrackingEnabled: false}); | ||
| await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, policy); | ||
|
|
||
| const {result} = renderHook(() => useAdvancedSearchFilters(), {wrapper}); | ||
|
|
@@ -268,8 +268,22 @@ describe('useAdvancedSearchFilters', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('shows attendee filter when isAttendeeTrackingEnabled is absent (Classic backwards compat)', async () => { | ||
| const policy = buildPolicy(1, {type: CONST.POLICY.TYPE.CORPORATE}); | ||
| // Ensure the property is truly absent, not just falsy | ||
| delete (policy as Record<string, unknown>).isAttendeeTrackingEnabled; | ||
| await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, policy); | ||
|
|
||
| const {result} = renderHook(() => useAdvancedSearchFilters(), {wrapper}); | ||
|
|
||
| await waitFor(() => { | ||
| const allKeys = result.current.typeFiltersKeys.flat(); | ||
| expect(allKeys).toContain(CONST.SEARCH.SYNTAX_FILTER_KEYS.ATTENDEE); | ||
| }); | ||
| }); | ||
|
|
||
| it('shows attendee filter when attendee tracking is enabled', async () => { | ||
| const policy = buildPolicy(1, {isAttendeeTrackingEnabled: true}); | ||
| const policy = buildPolicy(1, {type: CONST.POLICY.TYPE.CORPORATE, isAttendeeTrackingEnabled: true}); | ||
| await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, policy); | ||
|
|
||
| const {result} = renderHook(() => useAdvancedSearchFilters(), {wrapper}); | ||
|
|
@@ -378,6 +392,7 @@ describe('useAdvancedSearchFilters', () => { | |
| describe('cross-feature interaction', () => { | ||
| it('shows multiple filters when multiple features are enabled', async () => { | ||
| const policy = buildPolicy(1, { | ||
| type: CONST.POLICY.TYPE.CORPORATE, | ||
| areCategoriesEnabled: true, | ||
| areTagsEnabled: true, | ||
| isAttendeeTrackingEnabled: true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this fallback to
?? truecauses the ATTENDEE filter to be shown wheneverpolicyDerivedis temporarily undefined (e.g., initial Onyx load), unlike other feature-gated filters that default to hidden. That can surface an attendee filter in contexts where policy capabilities are not yet known and produce incorrect/flickering filter UI; the Classic compatibility behavior is already handled byisPolicyFeatureEnabled()once policy data is available.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm maybe. You could also argue the opposite that we're not showing the attendee selector when we should. Not going to block on this.