Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(customer-analytics): account list OR filters (#108569)

Arthur Moreira de Deusbcff77e977e8
diff --git a/docs/internal/customer-analytics/accounts-table.md b/docs/internal/customer-analytics/accounts-table.md
index 58cc17f1f42b..c159e8c6d865 100644
--- a/docs/internal/customer-analytics/accounts-table.md
+++ b/docs/internal/customer-analytics/accounts-table.md
@@ -10,8 +10,17 @@ Other query types keep their existing global or scene-specific concurrency limit
The Accounts list keeps unsaved filters when a user opens an account and returns to the list.
The draft includes search, tags, assignment filters, account property and relationship filters, and the selected overview tile filter.
+Account property, relationship, and custom-property filters can be placed in OR groups.
+Filters within each group use AND, while search, tags, assignment status, and selected overview tile filters apply to every group.
+Saved views and shared links keep the groups; older views without groups retain their AND behavior.
+A group that filters on churned or ignored accounts includes them only in that group; other groups still exclude them by default.
+When a saved condition refers to a deleted property, the list keeps the valid conditions in that group.
It also keeps sorting, selected columns, column display settings, and overview tile settings.
+The toolbar keeps a Filters button with a spaced, theme-aware accent count. The button highlights while the compact groups are open in a bordered area below it.
+Restored filters start collapsed. Relationship pills show member names using the same member list as the value picker. Adding the first condition opens the groups, and removing the last group restores the Filter button.
+Empty OR groups do not affect results. Search, tags, and assignment controls remain outside the editor.
+
The browser stores one draft per project and user in `sessionStorage`.
Draft restoration waits for the loaded project and user IDs before deciding whether to apply a saved view.
Automatic column updates do not replace the pending draft with default URL state.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 105203d56c49..c6623811775e 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8034,6 +8034,18 @@ snapshots:
hash: v1.k794b7964.4b8d5226ee154debdf333ff93d65a90ca766bcb25951e1baf36affb8b84b548d.dWZSHssPc83RkHVE-JPJA562bJR7MUim2yfqhjfNE50
scenes-app-customer-analytics-accounts--feature-gate-off--light:
hash: v1.k794b7964.e8b91bf6a0dd1b5d31064f4cbb94e9791e999c210831c455a498d0c7cc7e6bbb.IkZPJrJz33sKS8zzKwoy8V3s0GvmKpe5EGYTCIljhLs
+ scenes-app-customer-analytics-accounts--filter-groups-collapsed--dark:
+ hash: v1.k794b7964.d63ba89fb9d23da5d46059bbcaf5e3e9b32603186702468231ded3fd415e4320.uLtSHpIye9yIMjccXHJs2ZiiFSgaGdsA2VDfor5waMs
+ scenes-app-customer-analytics-accounts--filter-groups-collapsed--light:
+ hash: v1.k794b7964.8cdfcccaa619b8af27ac7dc3ca09cc5d8e99747aaff6c5f5502cba17f661bca7.mSjFC9lLV-BVU3MP4jDW3i40cr6r4PfGLG-M--xPrSQ
+ scenes-app-customer-analytics-accounts--filter-groups-expanded--dark:
+ hash: v1.k794b7964.3d191edced88b8e83efef8473846ae81d45e35b8c9d19181691dc937d4fdf8a3.yyCd7i_GySW9sPnH07JG-zrwAG8JrByWCNZObSBGXHU
+ scenes-app-customer-analytics-accounts--filter-groups-expanded--light:
+ hash: v1.k794b7964.7c8f07fbed9c1eee22da7ad86f9b9887507405e530d2e2abca8fc6bcc37387c2.7pHEWqCxENrhnZbb_FKcoEjGvoYOgbsIug6PKXgOcJM
+ scenes-app-customer-analytics-accounts--filter-groups-narrow--dark:
+ hash: v1.k794b7964.418e72f518e50090860ef9010c1490e7b26b2bad9f54d308f80506ea4db619b4.y61KRYRBw_1-fJzWzSHviYj7mNMQ5GZPUyVVT0pgxFo
+ scenes-app-customer-analytics-accounts--filter-groups-narrow--light:
+ hash: v1.k794b7964.f45c2a3028c57dfb15c2e920cbe17f8c4719bf0a4b678c57af013a628e59fe7c.bgetcxQYMZvG4VWXZgzrMV5t-4t1VdKTwRfpgS8ENcQ
scenes-app-customer-analytics-accounts--many-columns--dark:
hash: v1.k794b7964.c4c14cff203abdcb043554c234992f8f9c5fd402593321ac273ed11f56008c87.jOW1vwhYZ7YROPN6kZEfuCAK_dMmpXqNPwQ5LoqE-z4
scenes-app-customer-analytics-accounts--many-columns--light:
@@ -8067,9 +8079,9 @@ snapshots:
scenes-app-customer-analytics-accounts--row-expanded-pinned-properties-error--light:
hash: v1.k794b7964.5a08aeda76cd76b0203cdfaa8976522682bc1e83c70e62e4707f2b04cffb0634.zh56uPyuehDrM76JRt6h_aO3DdwqMUhE14dAx8BsUJ8
scenes-app-customer-analytics-accounts--row-expanded-pinned-properties-narrow--dark:
- hash: v1.k794b7964.0744617a1ccc1001d37549505a05ddd841e38c271b3dd074613a35cf89e510a3.YLhXPX1yCfuxgSj0xqsu5IIObl76j1_K83LsT9RFmSY
+ hash: v1.k794b7964.a810538ef741184c82d24d8c00f44494a0da2d3e086a4eb3229e6549a922b7e3.8hdyPnDByKor8aXfR01h8gkn2vLfhRLG1dvksykXCCI
scenes-app-customer-analytics-accounts--row-expanded-pinned-properties-narrow--light:
- hash: v1.k794b7964.5912ee881d6495f775a5249c9bc22a83707e68596688d859ff88af7b9d2cf6db.PVsL-j2sGlo7PBa7CLDfvUzf8yMgy9g5UnCUvRBZ67w
+ hash: v1.k794b7964.cedd8bbe22b7d3e236b784e1d018d007a12f51f3676d6133f912f1c4e9b265c7.l-utJ4fsDPlG6aoWvqqeBtLmgQGG_7qCvyaFF1ZtFW4
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--dark:
hash: v1.k794b7964.c52ec75dc9d1a1395448ca3a58bba70b8c43f8b676bff58dbdd7ae681256047a.PyQHfa6BWGInmt3T2c_8rZdl_ZO3Gi3Ruz7cOh-MGAI
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--light:
diff --git a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.test.tsx b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.test.tsx
index dc6f2372f8c3..5b6ad73606ca 100644
--- a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.test.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.test.tsx
@@ -1,8 +1,9 @@
import '@testing-library/jest-dom'
-import { render } from '@testing-library/react'
+import { render, waitFor } from '@testing-library/react'
import { Provider } from 'kea'
+import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
@@ -16,8 +17,8 @@ describe('PropertyFilterButton', () => {
// The content span carries a native `title` only when the rich group card
// tooltip is NOT used; a group-identity filter suppresses it and wraps the
// chip in the formatted-card Tooltip instead.
- const contentTitle = (): string | null =>
- document.querySelector('.PropertyFilterButton-content')?.getAttribute('title') ?? null
+ const contentTitle = (container: HTMLElement): string | null =>
+ container.querySelector('.PropertyFilterButton-content')?.getAttribute('title') ?? null
it.each([
{
@@ -41,16 +42,47 @@ describe('PropertyFilterButton', () => {
},
},
])('suppresses the native title (uses the group card tooltip) for $description', ({ item }) => {
- render(
+ const { container } = render(
<Provider>
<PropertyFilterButton item={item as AnyPropertyFilter} onClick={jest.fn()} />
</Provider>
)
- expect(document.querySelector('.PropertyFilterButton-content')).toBeInTheDocument()
+ expect(container.querySelector('.PropertyFilterButton-content')).toBeInTheDocument()
// Native title is suppressed; the formatted-card Tooltip is used instead.
// (The inverse — group *property* keys not triggering the card — is
// covered by the isGroupCardFilterKey() unit tests.)
- expect(contentTitle()).toBeNull()
+ expect(contentTitle(container)).toBeNull()
+ })
+ it('resolves relationship member names without opening the picker and keeps unknown IDs readable', async () => {
+ useMocks({
+ get: {
+ '/api/organizations/:organization_id/members/': {
+ count: 1,
+ next: null,
+ results: [
+ {
+ user: { id: 9001, first_name: 'Robin', last_name: 'Finch', email: '[email protected]' },
+ },
+ ],
+ },
+ },
+ })
+ const { container } = render(
+ <Provider>
+ <PropertyFilterButton
+ item={
+ {
+ type: PropertyFilterType.AccountRelationship,
+ key: 'example-relationship',
+ label: 'CSM',
+ operator: PropertyOperator.IsNot,
+ value: [9001, 9002],
+ } as unknown as AnyPropertyFilter
+ }
+ />
+ </Provider>
+ )
+ await waitFor(() => expect(contentTitle(container)).toContain('CSM ≠ Robin Finch, 9002'))
})
})
diff --git a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
index d26c913cca43..4e25167204f3 100644
--- a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
@@ -1,14 +1,15 @@
import './PropertyFilterButton.scss'
import clsx from 'clsx'
-import { useValues } from 'kea'
-import React from 'react'
+import { useActions, useValues } from 'kea'
+import React, { useEffect } from 'react'
import { IconX } from '@posthog/icons'
import { LemonButton, PopoverReferenceContext, Tooltip } from '@posthog/lemon-ui'
import { PropertyFilterIcon } from 'lib/components/PropertyFilters/components/PropertyFilterIcon'
-import { midEllipsis } from 'lib/utils/strings'
+import { fullNameOrEmail, midEllipsis } from 'lib/utils/strings'
+import { membersLogic } from 'scenes/organization/membersLogic'
import { cohortsModel } from '~/models/cohortsModel'
import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
@@ -16,6 +17,7 @@ import { AnyPropertyFilter, GroupPropertyFilter, GroupTypeIndex } from '~/types'
import {
formatPropertyLabel,
+ isAccountRelationshipPropertyFilter,
isBehavioralPropertyFilter,
isGroupCardFilterKey,
propertyFilterTypeToPropertyDefinitionType,
@@ -39,6 +41,14 @@ export const PropertyFilterButton = React.forwardRef<HTMLElement, PropertyFilter
const { cohortsById } = useValues(cohortsModel)
const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)
+ const { meFirstMembers } = useValues(membersLogic)
+ const { ensureAllMembersLoaded } = useActions(membersLogic)
+ useEffect(() => {
+ if (isAccountRelationshipPropertyFilter(item)) {
+ ensureAllMembersLoaded()
+ }
+ }, [item.type, ensureAllMembersLoaded])
+
const propertyDefinitionType = propertyFilterTypeToPropertyDefinitionType(item.type)
// A behavioral label is a whole sentence, which mid-ellipsis would turn into nonsense
@@ -46,17 +56,24 @@ export const PropertyFilterButton = React.forwardRef<HTMLElement, PropertyFilter
const label =
children ||
- formatPropertyLabel(
- item,
- cohortsById,
- (s) =>
+ formatPropertyLabel(item, cohortsById, (s) => {
+ if (isAccountRelationshipPropertyFilter(item)) {
+ return (Array.isArray(s) ? s : [s])
+ .map((id) => {
+ const member = meFirstMembers.find(({ user }) => String(user.id) === String(id))
+ return member ? fullNameOrEmail(member.user) : String(id)
+ })
+ .join(', ')
+ }
+ return (
formatPropertyValueForDisplay(
item.key,
s,
propertyDefinitionType,
(item as GroupPropertyFilter).group_type_index as GroupTypeIndex | undefined
)?.toString() || '?'
- )
+ )
+ })
// Don't render empty buttons
if (!label) {
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 72bfe3079d37..9559acbd082b 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -603,6 +603,19 @@
"required": ["kind"],
"type": "object"
},
+ "AccountsTablePropertyFilter": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/AccountsTableAccountFieldFilter"
+ },
+ {
+ "$ref": "#/definitions/AccountsTableRelationshipFilter"
+ },
+ {
+ "$ref": "#/definitions/AccountsTableCustomPropertyFilter"
+ }
+ ]
+ },
"AccountsTableQuery": {
"additionalProperties": false,
"properties": {
@@ -613,6 +626,16 @@
},
"type": "array"
},
+ "filterGroups": {
+ "description": "Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply.",
+ "items": {
+ "items": {
+ "$ref": "#/definitions/AccountsTablePropertyFilter"
+ },
+ "type": "array"
+ },
+ "type": "array"
+ },
"filters": {
"description": "Filters are combined with AND. Values within tag and assignment filters use OR.",
"items": {
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index e0a1a749d4ea..ff1ade248823 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -3275,6 +3275,11 @@ export type AccountsTableFilter =
| AccountsTableAccountFieldFilter
| AccountsTableCustomPropertyFilter
+export type AccountsTablePropertyFilter =
+ | AccountsTableAccountFieldFilter
+ | AccountsTableRelationshipFilter
+ | AccountsTableCustomPropertyFilter
+
export type AccountsTableCustomPropertyValue = string | number | boolean | null
export interface AccountsTableCustomPropertyHistoryPoint {
@@ -3325,6 +3330,8 @@ export interface AccountsTableQuery extends DataNode<AccountsTableQueryResponse>
columns: AccountsTableColumn[]
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
filters?: AccountsTableFilter[]
+ /** Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply. */
+ filterGroups?: AccountsTablePropertyFilter[][]
/** Aggregates to evaluate against the filtered account set. A metrics query skips row loading. */
metrics?: AccountsTableMetric[]
sort?: AccountsTableSort
diff --git a/posthog/schema.py b/posthog/schema.py
index d00f8dbcd502..1a8a50cd7baa 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -25809,6 +25809,18 @@ class AccountsTableQuery(BaseModel):
...,
description=("Columns to load for each account. Account identity fields are always returned."),
)
+ filterGroups: (
+ list[
+ list[AccountsTableAccountFieldFilter | AccountsTableRelationshipFilter | AccountsTableCustomPropertyFilter]
+ ]
+ | None
+ ) = Field(
+ default=None,
+ description=(
+ "Nonempty property-filter groups are ORed together; filters within each"
+ " group use AND. Global filters still apply."
+ ),
+ )
filters: (
list[
AccountsTableSearchFilter
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.py
index a199717f1430..13942645b07f 100644
--- a/products/customer_analytics/backend/facade/api.py
+++ b/products/customer_analytics/backend/facade/api.py
@@ -3185,7 +3185,10 @@ def _apply_account_table_filters(
team_id: int,
user_access_control: "UserAccessControl",
filters: tuple[contracts.AccountTableFilter, ...],
+ filter_groups: tuple[tuple[contracts.AccountTableFilter, ...], ...],
custom_property_display_types: dict[UUID, DisplayType],
+ include_churned: bool,
+ include_ignored: bool,
) -> QuerySet[Account]:
member_external_ids_by_query: dict[str, tuple[str, ...]] = {}
for filter_ in filters:
@@ -3198,13 +3201,35 @@ def _apply_account_table_filters(
break
try:
- return apply_account_filters(
+ queryset = apply_account_filters(
queryset,
team_id=team_id,
filters=filters,
custom_property_display_types=custom_property_display_types,
member_external_ids_by_query=member_external_ids_by_query,
)
+ if filter_groups:
+ matching_groups = Q()
+ for group in filter_groups:
+ group_query = queryset
+ branch_filters = filters + group
+ if not include_churned and not _filters_account_table_field(
+ branch_filters, contracts.AccountTableField.CHURNED_AT
+ ):
+ group_query = group_query.filter(churned_at__isnull=True)
+ if not include_ignored and not _filters_account_table_field(
+ branch_filters, contracts.AccountTableField.IGNORED_AT
+ ):
+ group_query = group_query.filter(ignored_at__isnull=True)
+ group_query = apply_account_filters(
+ group_query,
+ team_id=team_id,
+ filters=group,
+ custom_property_display_types=custom_property_display_types,
+ )
+ matching_groups |= Q(pk__in=group_query.order_by().values("pk"))
+ queryset = queryset.filter(matching_groups)
+ return queryset
except InvalidAccountFilter as error:
raise InvalidAccountTableColumn(str(error)) from error
@@ -3321,6 +3346,7 @@ def query_accounts_metrics(
user_access_control: "UserAccessControl",
filters: tuple[contracts.AccountTableFilter, ...],
metrics: tuple[contracts.AccountTableMetric, ...],
+ filter_groups: tuple[tuple[contracts.AccountTableFilter, ...], ...] = (),
include_churned: bool = False,
include_ignored: bool = False,
) -> list[float | int | None]:
@@ -3332,7 +3358,7 @@ def query_accounts_metrics(
custom_property_display_types = _validate_account_table_definitions(
team_id=team_id,
selection=contracts.AccountTableColumnSelection(custom_property_definition_ids=definition_ids),
- filters=filters,
+ filters=filters + tuple(filter_ for group in filter_groups for filter_ in group),
sort=None,
)
for definition_id in definition_ids:
@@ -3340,16 +3366,20 @@ def query_accounts_metrics(
raise InvalidAccountTableColumn("Account table metrics require numeric custom properties.")
accounts = _accounts_queryset(team_id, user_access_control)
- if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
- accounts = accounts.filter(churned_at__isnull=True)
- if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
- accounts = accounts.filter(ignored_at__isnull=True)
+ if not filter_groups:
+ if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
+ accounts = accounts.filter(churned_at__isnull=True)
+ if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
+ accounts = accounts.filter(ignored_at__isnull=True)
accounts = _apply_account_table_filters(
accounts,
team_id=team_id,
user_access_control=user_access_control,
filters=filters,
+ filter_groups=filter_groups,
custom_property_display_types=custom_property_display_types,
+ include_churned=include_churned,
+ include_ignored=include_ignored,
)
results: list[float | int | None] = [None] * len(metrics)
for index, metric in enumerate(metrics):
@@ -3418,27 +3448,32 @@ def query_accounts_table(
sort: contracts.AccountTableSort | None,
offset: int,
limit: int,
+ filter_groups: tuple[tuple[contracts.AccountTableFilter, ...], ...] = (),
include_churned: bool = False,
include_ignored: bool = False,
) -> contracts.AccountTablePage:
custom_property_display_types = _validate_account_table_definitions(
team_id=team_id,
selection=selection,
- filters=filters,
+ filters=filters + tuple(filter_ for group in filter_groups for filter_ in group),
sort=sort,
)
queryset = _accounts_queryset(team_id, user_access_control)
- if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
- queryset = queryset.filter(churned_at__isnull=True)
- if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
- queryset = queryset.filter(ignored_at__isnull=True)
+ if not filter_groups:
+ if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
+ queryset = queryset.filter(churned_at__isnull=True)
+ if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
+ queryset = queryset.filter(ignored_at__isnull=True)
queryset = _apply_account_table_filters(
queryset,
team_id=team_id,
user_access_control=user_access_control,
filters=filters,
+ filter_groups=filter_groups,
custom_property_display_types=custom_property_display_types,
+ include_churned=include_churned,
+ include_ignored=include_ignored,
)
queryset = _apply_account_table_sort(
queryset,
diff --git a/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py b/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
index cd78c8cc9954..1dc2b105f615 100644
--- a/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
+++ b/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
@@ -1,3 +1,4 @@
+from collections.abc import Sequence
from typing import NoReturn
from uuid import UUID
@@ -44,6 +45,19 @@ ACCOUNTS_TABLE_MAX_FILTER_VALUES = 100
ACCOUNTS_TABLE_MAX_METRICS = 5
ACCOUNTS_TABLE_MAX_PAGE_SIZE = 500
ACCOUNTS_TABLE_MAX_STRING_LENGTH = 1_000
+ACCOUNTS_TABLE_MAX_FILTER_GROUPS = 10
+
+AccountsTableQueryFilter = (
+ AccountsTableSearchFilter
+ | AccountsTableTagsFilter
+ | AccountsTableAssignedToFilter
+ | AccountsTableAssignedFilter
+ | AccountsTableUnassignedFilter
+ | AccountsTableRelationshipFilter
+ | AccountsTableAccountIdFilter
+ | AccountsTableAccountFieldFilter
+ | AccountsTableCustomPropertyFilter
+)
class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse]):
@@ -117,8 +131,10 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
custom_property_history_windows=custom_property_history_windows,
)
- def _filters(self) -> tuple[contracts.AccountTableFilter, ...]:
- query_filters = self.query.filters or []
+ def _filters(
+ self, query_filters: Sequence[AccountsTableQueryFilter] | None = None
+ ) -> tuple[contracts.AccountTableFilter, ...]:
+ query_filters = (self.query.filters or []) if query_filters is None else query_filters
if len(query_filters) > ACCOUNTS_TABLE_MAX_FILTERS:
raise ValidationError(f"Account table queries support up to {ACCOUNTS_TABLE_MAX_FILTERS} filters.")
if sum(isinstance(filter_, AccountsTableSearchFilter) for filter_ in query_filters) > 1:
@@ -195,6 +211,18 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
raise ValidationError("Account table filter IDs must be valid UUIDs.") from error
return tuple(filters)
+ def _filter_groups(self) -> tuple[tuple[contracts.AccountTableFilter, ...], ...]:
+ groups = self.query.filterGroups or []
+ if len(groups) > ACCOUNTS_TABLE_MAX_FILTER_GROUPS:
+ raise ValidationError(
+ f"Account table queries support up to {ACCOUNTS_TABLE_MAX_FILTER_GROUPS} filter groups."
+ )
+ if any(not group for group in groups):
+ raise ValidationError("Account table filter groups cannot be empty.")
+ if len(self.query.filters or []) + sum(len(group) for group in groups) > ACCOUNTS_TABLE_MAX_FILTERS:
+ raise ValidationError(f"Account table queries support up to {ACCOUNTS_TABLE_MAX_FILTERS} filters.")
+ return tuple(self._filters(group) for group in groups)
+
def _sort(self) -> contracts.AccountTableSort | None:
if self.query.sort is None:
return None
@@ -269,6 +297,7 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
)
offset = max(self.query.offset or 0, 0)
filters = self._filters()
+ filter_groups = self._filter_groups()
try:
if self.query.metrics is not None:
@@ -276,6 +305,7 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
team_id=self.team.id,
user_access_control=user_access_control,
filters=filters,
+ filter_groups=filter_groups,
metrics=self._metrics(),
include_churned=bool(self.query.includeChurned),
include_ignored=bool(self.query.includeIgnored),
@@ -292,6 +322,7 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
user_access_control=user_access_control,
selection=self._column_selection(),
filters=filters,
+ filter_groups=filter_groups,
sort=self._sort(),
offset=offset,
limit=limit,
diff --git a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
index 1a6952144c28..1599af69de71 100644
--- a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
+++ b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
@@ -587,6 +587,107 @@ class TestAccountsTableQueryRunner(BaseTest):
assert [row.id for row in response.results] == [str(csm_account.id)]
+ def test_property_groups_match_either_branch_and_apply_global_filters_to_rows_and_metrics(self) -> None:
+ definition = AccountRelationshipDefinition.objects.unscoped().create(team=self.team, name="CSM")
+ staged_owner = create_custom_property_definition(
+ team_id=self.team.id, name="Staged owner", display_type=DisplayType.TEXT
+ )
+ current = create_account(team_id=self.team.id, name="Account current")
+ reassigned = create_account(team_id=self.team.id, name="Account reassigned")
+ incoming = create_account(team_id=self.team.id, name="Account incoming")
+ create_account(team_id=self.team.id, name="Account unrelated")
+ ignored = create_account(team_id=self.team.id, name="Other incoming")
+ for account in (current, reassigned):
+ AccountRelationship.objects.unscoped().create(
+ team=self.team, account=account, definition=definition, user=self.user
+ )
+ for account, value in (
+ (reassigned, "[email protected]"),
+ (incoming, "[email protected]"),
+ (ignored, "[email protected]"),
+ ):
+ CustomPropertyValue.objects.unscoped().create(
+ team=self.team, account=account, definition=staged_owner, value_str=value
+ )
+
+ groups = [
+ [
+ AccountsTableRelationshipFilter(
+ definitionId=str(definition.id),
+ operator=AccountsTableRelationshipOperator.EXACT,
+ userIds=[self.user.id],
+ ),
+ AccountsTableCustomPropertyFilter(
+ definitionId=str(staged_owner.id), operator=AccountsTableCustomPropertyOperator.IS_NOT_SET
+ ),
+ ],
+ [
+ AccountsTableCustomPropertyFilter(
+ definitionId=str(staged_owner.id),
+ operator=AccountsTableCustomPropertyOperator.EXACT,
+ values=["[email protected]"],
+ )
+ ],
+ ]
+ query = AccountsTableQuery(
+ columns=[], filters=[AccountsTableSearchFilter(query="Account")], filterGroups=groups
+ )
+ rows = self._run(query).results
+ metrics = self._run(
+ AccountsTableQuery(
+ columns=[],
+ filters=[AccountsTableSearchFilter(query="Account")],
+ filterGroups=groups,
+ metrics=[AccountsTableCountMetric()],
+ )
+ ).metricsResults
+
+ assert {row.name for row in rows} == {"Account current", "Account incoming"}
+ assert metrics == [2]
+
+ @parameterized.expand(
+ [
+ ("churned", AccountsTableAccountField.CHURNED_AT),
+ ("ignored", AccountsTableAccountField.IGNORED_AT),
+ ]
+ )
+ def test_lifecycle_filter_in_one_group_does_not_widen_other_groups(
+ self, _name: str, lifecycle_field: AccountsTableAccountField
+ ) -> None:
+ timestamp = datetime(2026, 1, 1, tzinfo=UTC)
+ churned_at = timestamp if lifecycle_field == AccountsTableAccountField.CHURNED_AT else None
+ ignored_at = timestamp if lifecycle_field == AccountsTableAccountField.IGNORED_AT else None
+ create_account(team_id=self.team.id, name="Shared active")
+ create_account(team_id=self.team.id, name="Shared hidden", churned_at=churned_at, ignored_at=ignored_at)
+ create_account(team_id=self.team.id, name="Target hidden", churned_at=churned_at, ignored_at=ignored_at)
+ groups = [
+ [
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.NAME,
+ operator=AccountsTableAccountFieldOperator.ICONTAINS,
+ values=["Shared"],
+ )
+ ],
+ [
+ AccountsTableAccountFieldFilter(
+ field=lifecycle_field, operator=AccountsTableAccountFieldOperator.IS_SET
+ ),
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.NAME,
+ operator=AccountsTableAccountFieldOperator.EXACT,
+ values=["Target hidden"],
+ ),
+ ],
+ ]
+
+ rows = self._run(AccountsTableQuery(columns=[], filterGroups=groups)).results
+ metrics = self._run(
+ AccountsTableQuery(columns=[], filterGroups=groups, metrics=[AccountsTableCountMetric()])
+ ).metricsResults
+
+ assert {row.name for row in rows} == {"Shared active", "Target hidden"}
+ assert metrics == [2]
+
def test_unassigned_and_account_id_filters(self) -> None:
assigned_account = create_account(team_id=self.team.id, name="Assigned")
unassigned_account = create_account(team_id=self.team.id, name="Unassigned")
@@ -928,6 +1029,14 @@ class TestAccountsTableQueryRunner(BaseTest):
)
)
+ name_filter = AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.NAME,
+ operator=AccountsTableAccountFieldOperator.IS_SET,
+ )
+ for groups in ([], [name_filter] * (ACCOUNTS_TABLE_MAX_FILTERS + 1)):
+ with self.assertRaises(ValidationError):
+ self._run(AccountsTableQuery(columns=[], filterGroups=[groups]))
+
def test_rejects_excessive_custom_property_filter_values(self) -> None:
definition = create_custom_property_definition(
team_id=self.team.id,
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index e84e82bfd617..9250da42894a 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -21,8 +21,9 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
└─ binds dataNodeLogic(ACCOUNTS_METRICS_DATA_NODE_KEY, accountsLogic.metricsQuery) [overview tiles, metrics-only]
├── AccountsMaxTools registers the `open_account` Max contextual tool → accountsLogic.openAccount
├── AccountsTabFilters two rows: (1) search + Refresh; (2) tags / "assigned to" (assignment-status picker) /
-│ "my accounts" / native-field, relationship, and custom-property filters on the left,
+│ "my accounts" / empty Filter trigger on the left,
│ AccountsOverviewTilesButton + AccountsColumnConfigurator on the right
+├── AccountsFilterGroups toolbar count button; shared PropertyFilters in compact cards below global controls, OR dividers
├── AccountsOverviewTiles metric tiles across the filtered set
└── AccountsTable the DataTable; keyed row renderers; controlled row expansion
└── passes a memoized DataTable context, so unrelated state updates keep memoized table rows intact
@@ -116,7 +117,7 @@ The Postgres runner returns `{ timestamp, value }` history points ascending (wit
Fewer than 2 in-window points falls back to rendering the latest value plainly.
The config persists per view via `ColumnConfiguration.properties.column_display` (round-tripped in `accountsViewState.ts`), and sorting uses the scalar custom property even when the displayed cell loads history.
-**Account filters** use one shared `PropertyFilters` control with three groups: native Account fields, Account relationships, and Account custom properties.
+**Account filters** live in `AccountsFilterGroups`, using a selected `LemonButton` with a spaced accent-colored count and compact `LemonCard` groups without headings inside a bordered filter area. Restored filters start collapsed. The shared `PropertyFilterButton` resolves relationship values through `membersLogic`, matching the member picker. The empty state shows only the shared Filter trigger; completing the first condition expands the editor. Removing the first group promotes the next branch via `removeFirstAccountFilterGroup`. Collapse is local presentation state and does not change saved filters. They reuse `PropertyFilters` for each OR branch; filters within a branch use AND. The first branch keeps the legacy flat `accountFilters` state, and further branches live in `accountFilterGroups`. Each branch offers native Account fields, Account relationships, and Account custom properties. Search, tags, assignment status, and tile filters remain global AND restrictions. The query planner sends multiple nonempty branches as `filterGroups` to the Postgres runner. Saved views, shared URL hashes, and session drafts persist the branches; legacy flat views keep their AND behavior.
Relationship options come from the team's relationship definitions. They use the shared member picker and support matching a specific member, excluding a member, and checking whether a relationship is assigned.
Native fields cover names, external and connection IDs, created and updated timestamps, and the `churned_at` and `ignored_at` lifecycle timestamps. Text fields support exact, negative, contains, and set operators. Timestamp fields support exact date, before, after, and set operators. A lifecycle timestamp filter includes that normally hidden state before applying its predicate, so `Ignored at is set` returns ignored accounts while an unfiltered list still hides them.
Custom property options come from `accountsColumnConfigLogic.customPropertyTaxonomicOptions` via `optionsFromProp`. The filter `key` is the stable definition ID, and the definition name rides on the filter's `label` for display.
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsFilterGroups.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsFilterGroups.tsx
new file mode 100644
index 000000000000..7abee17a2119
--- /dev/null
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsFilterGroups.tsx
@@ -0,0 +1,156 @@
+import { useActions, useValues } from 'kea'
+import { Fragment, useId, useState } from 'react'
+
+import { IconFilter, IconPlusSmall, IconTrash } from '@posthog/icons'
+import { LemonBadge, LemonButton, LemonCard, LemonDivider } from '@posthog/lemon-ui'
+
+import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import type { AnyPropertyFilter } from '~/types'
+
+import { AccountRelationshipOperatorValueSelect } from './AccountRelationshipOperatorValueSelect'
+import { accountsColumnConfigLogic } from './accountsColumnConfigLogic'
+import { accountsLogic } from './accountsLogic'
+import {
+ ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
+ ACCOUNT_FILTER_OPERATOR_ALLOWLIST,
+ accountFilterStaticValueOptions,
+ isAccountRelationshipFilter,
+ type AccountFilter,
+} from './accountsPropertyFilters'
+
+export function AccountsFilterGroups(): JSX.Element {
+ const { accountFilters, accountFilterGroups } = useValues(accountsLogic)
+ const {
+ updateAccountFilters,
+ addAccountFilterGroup,
+ removeFirstAccountFilterGroup,
+ removeAccountFilterGroup,
+ updateAccountFilterGroup,
+ } = useActions(accountsLogic)
+ const { customPropertyTaxonomicOptions, relationshipTaxonomicOptions } = useValues(accountsColumnConfigLogic)
+ const detailsId = useId()
+ const [expanded, setExpanded] = useState(false)
+ const groups = [accountFilters, ...accountFilterGroups]
+ const count = groups.reduce((total, group) => total + group.length, 0)
+ const hasGroups = count > 0 || accountFilterGroups.length > 0
+ function renderFilters(filters: AccountFilter[], groupIndex: number): JSX.Element {
+ return (
+ <PropertyFilters
+ propertyFilters={filters as AnyPropertyFilter[]}
+ onChange={(updatedFilters) => {
+ setExpanded(true)
+ if (groupIndex === 0) {
+ updateAccountFilters(updatedFilters as AccountFilter[])
+ } else {
+ updateAccountFilterGroup(groupIndex - 1, updatedFilters as AccountFilter[])
+ }
+ }}
+ pageKey={`customer-analytics-accounts-custom-properties-${groupIndex}`}
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.AccountFields,
+ TaxonomicFilterGroupType.AccountRelationships,
+ TaxonomicFilterGroupType.AccountCustomProperties,
+ ]}
+ taxonomicFilterOptionsFromProp={{
+ [TaxonomicFilterGroupType.AccountFields]: ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
+ [TaxonomicFilterGroupType.AccountRelationships]: relationshipTaxonomicOptions,
+ [TaxonomicFilterGroupType.AccountCustomProperties]: customPropertyTaxonomicOptions,
+ }}
+ operatorAllowlist={ACCOUNT_FILTER_OPERATOR_ALLOWLIST}
+ staticValueOptions={accountFilterStaticValueOptions}
+ renderOperatorValueSelect={(filter, onChange) =>
+ isAccountRelationshipFilter(filter) ? (
+ <AccountRelationshipOperatorValueSelect filter={filter} onChange={onChange} />
+ ) : null
+ }
+ buttonSize="small"
+ buttonText={hasGroups ? 'Add condition' : 'Filter'}
+ showConditionBadge
+ hasRowOperator
+ />
+ )
+ }
+
+ if (!hasGroups) {
+ return renderFilters(accountFilters, 0)
+ }
+
+ return (
+ <>
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconFilter />}
+ active={expanded}
+ aria-expanded={expanded}
+ aria-controls={expanded ? detailsId : undefined}
+ onClick={() => setExpanded(!expanded)}
+ data-attr="accounts-toggle-filter-groups"
+ >
+ <span className="flex items-center gap-2">
+ <span>Filters</span>
+ <LemonBadge.Number count={count} maxDigits={3} status="primary" />
+ </span>
+ </LemonButton>
+ {expanded && (
+ <LemonCard
+ hoverEffect={false}
+ className="w-full min-w-0 order-last p-2 bg-surface-secondary"
+ data-attr="accounts-filter-details"
+ >
+ <div id={detailsId} className="flex flex-col gap-2">
+ {groups.map((filters, groupIndex) => (
+ <Fragment key={groupIndex}>
+ {groupIndex > 0 && (
+ <div className="flex items-center gap-2" aria-label="OR">
+ <LemonDivider className="flex-1 my-0" />
+ <span className="text-xs font-semibold text-muted">OR</span>
+ <LemonDivider className="flex-1 my-0" />
+ </div>
+ )}
+ <LemonCard
+ hoverEffect={false}
+ className="p-2 min-w-0 flex items-start gap-2"
+ data-attr="accounts-filter-group"
+ >
+ <div className="flex-1 min-w-0">{renderFilters(filters, groupIndex)}</div>
+ <LemonButton
+ size="xsmall"
+ icon={<IconTrash />}
+ aria-label={`Remove group ${String.fromCharCode(65 + groupIndex)}`}
+ tooltip="Remove group"
+ onClick={() =>
+ groupIndex === 0
+ ? removeFirstAccountFilterGroup()
+ : removeAccountFilterGroup(groupIndex - 1)
+ }
+ data-attr="accounts-remove-or-group"
+ />
+ </LemonCard>
+ </Fragment>
+ ))}
+ <LemonButton
+ type="tertiary"
+ size="small"
+ className="self-start"
+ icon={<IconPlusSmall />}
+ onClick={addAccountFilterGroup}
+ disabledReason={
+ groups.some((group) => group.length === 0)
+ ? 'Add a condition to each group first'
+ : groups.length >= 10
+ ? 'You can add up to 10 groups'
+ : undefined
+ }
+ data-attr="accounts-add-or-group"
+ >
+ Add OR group
+ </LemonButton>
+ </div>
+ </LemonCard>
+ )}
+ </>
+ )
+}
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
index 5da98ff21b61..13a1de39f2c9 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
@@ -8,6 +8,7 @@ import { urls } from 'scenes/urls'
import { mswDecorator } from '~/mocks/browser'
import type { MockResolverInfo, Mocks } from '~/mocks/utils'
+import { PropertyFilterType, PropertyOperator } from '~/types'
import type {
CustomPropertyDefinitionApi,
@@ -1036,3 +1037,63 @@ export const RowExpandedUsageNotFound: Story = {
await canvas.findByText('No billing usage insight here', {}, { timeout: 15000 })
},
}
+
+export const FilterGroupsCollapsed: Story = {
+ ...Default,
+ parameters: {
+ pageUrl: `${urls.customerAnalyticsAccounts()}#view=${encodeURIComponent(
+ JSON.stringify({
+ customProperties: [
+ {
+ type: PropertyFilterType.Account,
+ key: 'name',
+ label: 'Name',
+ operator: PropertyOperator.IContains,
+ value: 'Acme',
+ },
+ {
+ type: PropertyFilterType.Account,
+ key: 'external_id',
+ label: 'External ID',
+ operator: PropertyOperator.IsSet,
+ },
+ ],
+ filterGroups: [
+ [
+ {
+ type: PropertyFilterType.Account,
+ key: 'name',
+ label: 'Name',
+ operator: PropertyOperator.IContains,
+ value: 'Globex',
+ },
+ ],
+ ],
+ })
+ )}`,
+ testOptions: { waitForSelector: '[data-attr="accounts-toggle-filter-groups"]' },
+ },
+}
+
+export const FilterGroupsExpanded: Story = {
+ ...FilterGroupsCollapsed,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ await userEvent.click(await canvas.findByText('Filters'))
+ await canvas.findByText('Add OR group')
+ },
+}
+
+export const FilterGroupsNarrow: Story = {
+ ...FilterGroupsExpanded,
+ decorators: [
+ mswDecorator({
+ post: { [QUERY_ENDPOINT]: mockAccountsTableQuery(SAMPLE_ROWS) },
+ }),
+ (Story) => (
+ <div className="max-w-3xl">
+ <Story />
+ </div>
+ ),
+ ],
+}
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
index 92ec798c5fe8..4e642fa9c4e4 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
@@ -8,7 +8,7 @@ import { userLogic } from 'scenes/userLogic'
import { useMocks } from '~/mocks/jest'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { initKeaTests } from '~/test/init'
-import type { UserType } from '~/types'
+import { PropertyFilterType, PropertyOperator, type UserType } from '~/types'
import type { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
@@ -151,4 +151,44 @@ describe('AccountsTabFilters', () => {
expect(logic.values.assignmentStatus).toBe('assigned')
})
+ it('keeps OR branches when collapsed and returns to the empty trigger after removing every group', async () => {
+ const first = [
+ {
+ type: PropertyFilterType.Account as const,
+ key: 'name',
+ operator: PropertyOperator.Exact,
+ value: ['Acme'],
+ },
+ ]
+ const second = [
+ {
+ type: PropertyFilterType.Account as const,
+ key: 'name',
+ operator: PropertyOperator.Exact,
+ value: ['Globex'],
+ },
+ ]
+ logic.actions.setAccountFilters(first)
+ logic.actions.setAccountFilterGroups([second])
+ renderFilters()
+
+ expect(screen.queryByText('Add OR group')).not.toBeInTheDocument()
+ expect(screen.getByText('Filters').closest('button')).toHaveAttribute('aria-expanded', 'false')
+ fireEvent.click(screen.getByText('Filters'))
+ expect(screen.getByText('Filters').closest('button')).toHaveAttribute('aria-expanded', 'true')
+ expect(screen.queryByText('Match all conditions')).not.toBeInTheDocument()
+ expect(await screen.findByText('Add OR group')).toBeInTheDocument()
+ fireEvent.click(screen.getByText('Filters'))
+ expect(logic.values.accountFilters).toEqual(first)
+ expect(logic.values.accountFilterGroups).toEqual([second])
+
+ fireEvent.click(screen.getByText('Filters'))
+ fireEvent.click(await screen.findByLabelText('Remove group A'))
+ expect(logic.values.accountFilters).toEqual(second)
+ expect(logic.values.accountFilterGroups).toEqual([])
+ fireEvent.click(screen.getByLabelText('Remove group A'))
+ expect(await screen.findByText('Filter')).toBeInTheDocument()
+ expect(screen.queryByText('Filters')).not.toBeInTheDocument()
+ expect(logic.values.accountFilters).toEqual([])
+ })
})
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
index 67a8f60b23c7..a268eba0a373 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
@@ -4,29 +4,18 @@ import { IconChevronDown, IconRefresh, IconX } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput, LemonInputSelect } from '@posthog/lemon-ui'
import { AccountAssignmentFilter } from 'lib/components/AccountAssignmentFilter/AccountAssignmentFilter'
-import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
-import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { tagsModel } from '~/models/tagsModel'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
-import type { AnyPropertyFilter } from '~/types'
-import { AccountRelationshipOperatorValueSelect } from './AccountRelationshipOperatorValueSelect'
-import { accountsColumnConfigLogic } from './accountsColumnConfigLogic'
import { AccountsColumnConfigurator } from './AccountsColumnConfigurator'
+import { AccountsFilterGroups } from './AccountsFilterGroups'
import { accountsLogic } from './accountsLogic'
import { AccountsOverviewTilesButton } from './AccountsOverviewTilesButton'
-import {
- ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
- ACCOUNT_FILTER_OPERATOR_ALLOWLIST,
- accountFilterStaticValueOptions,
- isAccountRelationshipFilter,
- type AccountFilter,
-} from './accountsPropertyFilters'
import { AccountsViewSelector } from './AccountsViewSelector'
export function AccountsTabFilters(): JSX.Element {
- const { searchInput, tagsFilter, assignmentStatus, assignedToCurrentUser, assignedToFilter, accountFilters } =
+ const { searchInput, tagsFilter, assignmentStatus, assignedToCurrentUser, assignedToFilter } =
useValues(accountsLogic)
const { responseLoading: accountsLoading } = useValues(dataNodeLogic)
const {
@@ -35,13 +24,11 @@ export function AccountsTabFilters(): JSX.Element {
setAssignmentStatus,
setAssignedToCurrentUser,
setAssignedToFilter,
- updateAccountFilters,
refresh,
reportFilterChange,
} = useActions(accountsLogic)
const { tags: tagsAvailable, tagsLoading } = useValues(tagsModel)
const { loadTagsIfNeeded } = useActions(tagsModel)
- const { customPropertyTaxonomicOptions, relationshipTaxonomicOptions } = useValues(accountsColumnConfigLogic)
const tagsButtonLabel =
tagsFilter.length === 0 ? 'All tags' : tagsFilter.length === 1 ? tagsFilter[0] : `${tagsFilter.length} tags`
@@ -73,8 +60,8 @@ export function AccountsTabFilters(): JSX.Element {
Refresh
</LemonButton>
</div>
- <div className="flex flex-wrap gap-2 items-center justify-between">
- <div className="flex flex-wrap gap-2 items-center">
+ <div className="flex flex-wrap gap-2 items-center">
+ <div className="contents">
<LemonDropdown
closeOnClickInside={false}
onVisibilityChange={(open) => open && loadTagsIfNeeded()}
@@ -157,32 +144,9 @@ export function AccountsTabFilters(): JSX.Element {
data-attr="accounts-my-accounts-filter"
/>
- <PropertyFilters
- propertyFilters={accountFilters as unknown as AnyPropertyFilter[]}
- onChange={(filters) => updateAccountFilters(filters as unknown as AccountFilter[])}
- pageKey="customer-analytics-accounts-custom-properties"
- taxonomicGroupTypes={[
- TaxonomicFilterGroupType.AccountFields,
- TaxonomicFilterGroupType.AccountRelationships,
- TaxonomicFilterGroupType.AccountCustomProperties,
- ]}
- taxonomicFilterOptionsFromProp={{
- [TaxonomicFilterGroupType.AccountFields]: ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
- [TaxonomicFilterGroupType.AccountRelationships]: relationshipTaxonomicOptions,
- [TaxonomicFilterGroupType.AccountCustomProperties]: customPropertyTaxonomicOptions,
- }}
- operatorAllowlist={ACCOUNT_FILTER_OPERATOR_ALLOWLIST}
- staticValueOptions={accountFilterStaticValueOptions}
- renderOperatorValueSelect={(filter, onChange) =>
- isAccountRelationshipFilter(filter) ? (
- <AccountRelationshipOperatorValueSelect filter={filter} onChange={onChange} />
- ) : null
- }
- buttonSize="small"
- hasRowOperator={false}
- />
+ <AccountsFilterGroups />
</div>
- <div className="flex flex-wrap gap-2 items-center">
+ <div className="flex flex-wrap gap-2 items-center ml-auto">
<AccountsOverviewTilesButton />
<AccountsColumnConfigurator />
</div>
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
index e752f9a44c6a..b665f9b049a8 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
@@ -308,8 +308,21 @@ describe('accountsLogic', () => {
},
])
+ logic.actions.setAccountFilterGroups([
+ [
+ ACCOUNT_FILTERS[0],
+ {
+ type: PropertyFilterType.AccountCustomProperty,
+ key: '99999999-9999-9999-9999-999999999999',
+ operator: PropertyOperator.Exact,
+ value: 'missing',
+ },
+ ],
+ ])
+
expect(logic.values.accountFilters).toEqual([])
- expect(logic.values.activeFilterCount).toBe(0)
+ expect(logic.values.accountFilterGroups).toEqual([[ACCOUNT_FILTERS[0]]])
+ expect(logic.values.activeFilterCount).toBe(1)
})
it('adds native account filters to the query and shareable view state', () => {
@@ -356,6 +369,23 @@ describe('accountsLogic', () => {
expect(capture.mock.calls.at(-1)?.[1]).not.toHaveProperty('value')
})
+ it('tracks edits to OR groups without tracking restored state', () => {
+ const capture = jest.spyOn(posthog, 'capture').mockImplementation()
+ logic.actions.setAccountFilters([ACCOUNT_FILTERS[0]])
+ logic.actions.setAccountFilterGroups([[ACCOUNT_FILTERS[0]]])
+ expect(capture).not.toHaveBeenCalledWith(AccountsEvents.FilterChanged, expect.anything())
+
+ logic.actions.updateAccountFilterGroup(0, [ACCOUNT_FILTERS[1]])
+ logic.actions.addAccountFilterGroup()
+ logic.actions.removeAccountFilterGroup(1)
+
+ expect(capture.mock.calls.filter(([event]) => event === AccountsEvents.FilterChanged)).toEqual([
+ [AccountsEvents.FilterChanged, expect.objectContaining({ filter_type: 'or_group', group_count: 2 })],
+ [AccountsEvents.FilterChanged, expect.objectContaining({ filter_type: 'or_group', group_count: 3 })],
+ [AccountsEvents.FilterChanged, expect.objectContaining({ filter_type: 'or_group', group_count: 2 })],
+ ])
+ })
+
it('setTagsFilter updates the reducer', () => {
logic.actions.setTagsFilter(['enterprise'])
expect(logic.values.tagsFilter).toEqual(['enterprise'])
@@ -412,6 +442,7 @@ describe('accountsLogic', () => {
tags: [],
tileFilter: null,
customProperties: [],
+ filterGroups: [],
},
tiles: [...DEFAULT_TILES],
columnDisplay: {},
@@ -479,6 +510,36 @@ describe('accountsLogic', () => {
expect(logic.values.activeFilterCount).toBe(0)
})
+ it('keeps custom-property groups until definitions load after a relationship failure', async () => {
+ logic.unmount()
+ silenceKeaLoadersErrors()
+ let resolveDefinitions!: (result: Awaited<ReturnType<typeof customPropertyDefinitionsList>>) => void
+ mockCustomPropertiesList.mockReturnValueOnce(
+ new Promise<Awaited<ReturnType<typeof customPropertyDefinitionsList>>>((resolve) => {
+ resolveDefinitions = resolve
+ })
+ )
+ mockDefinitionsList.mockRejectedValueOnce(new Error('network'))
+ logic = accountsLogic()
+ logic.mount()
+ const customFilter = {
+ type: PropertyFilterType.AccountCustomProperty as const,
+ key: CSM_DEFINITION_ID,
+ operator: PropertyOperator.Exact,
+ value: 5,
+ }
+ logic.actions.setAccountFilterGroups([[customFilter]])
+
+ await expectLogic(accountsColumnConfigLogic.findMounted()!).toDispatchActions([
+ 'loadRelationshipDefinitionsFailure',
+ ])
+ expect(logic.values.accountFilterGroups).toEqual([[customFilter]])
+
+ resolveDefinitions({ count: 1, results: [buildCustomPropertyDefinition({ id: CSM_DEFINITION_ID })] })
+ await expectLogic(accountsColumnConfigLogic.findMounted()!).toFinishAllListeners()
+ expect(logic.values.accountFilterGroups).toEqual([[customFilter]])
+ })
+
it('keeps overview metrics off the list query', () => {
expect(logic.values.accountsQuerySource?.metrics).toBeUndefined()
})
@@ -1108,6 +1169,24 @@ describe('accountsLogic', () => {
tags: ['enterprise'],
assignedTo: [7],
columns: [ACCOUNTS_NAME_COLUMN, 'csm'],
+ customProperties: [
+ {
+ type: PropertyFilterType.Account,
+ key: AccountsTableAccountField.Name,
+ operator: PropertyOperator.IsSet,
+ value: null,
+ },
+ ],
+ filterGroups: [
+ [
+ {
+ type: PropertyFilterType.Account,
+ key: AccountsTableAccountField.ExternalId,
+ operator: PropertyOperator.IsSet,
+ value: null,
+ },
+ ],
+ ],
},
}
)
@@ -1124,6 +1203,10 @@ describe('accountsLogic', () => {
{ kind: 'tags', tagNames: ['enterprise'] },
{ kind: 'assigned_to', userIds: [7] },
])
+ expect(source.filterGroups).toEqual([
+ [{ kind: 'account_field', field: 'name', operator: 'is_set', values: [] }],
+ [{ kind: 'account_field', field: 'external_id', operator: 'is_set', values: [] }],
+ ])
})
it('restores columns from the view hash param', async () => {
@@ -1343,6 +1426,16 @@ describe('accountsLogic', () => {
expect(logic.values.accountsQuerySource?.filters).toEqual([{ kind: 'account_id', accountId: ACCOUNT_ID }])
})
+ it('clears OR groups when opening an account hidden by the current filters', () => {
+ logic.actions.setAccountFilters([ACCOUNT_FILTERS[0]])
+ logic.actions.setAccountFilterGroups([[ACCOUNT_FILTERS[0]]])
+
+ logic.actions.openAccount(ACCOUNT_ID, 'target-account', 'Target account', DEFAULT_ACCOUNT_TAB)
+
+ expect(logic.values.accountFilters).toEqual([])
+ expect(logic.values.accountFilterGroups).toEqual([])
+ })
+
it('survives a view-state restore rewriting the URL', async () => {
router.actions.push(urls.customerAnalyticsAccount(ACCOUNT_ID, 'usage'))
await expectLogic(logic).toFinishAllListeners()
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
index 5702d28c1564..cf374959aa7d 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
@@ -114,7 +114,7 @@ function clearSortIfColumnRemoved(values: SortLikeValues, actions: SortLikeActio
export type RoleFilterValue = number[]
-export type AccountFilterType = 'tag' | 'assignment_status' | 'my_accounts' | 'assigned_to'
+export type AccountFilterType = 'tag' | 'assignment_status' | 'my_accounts' | 'assigned_to' | 'or_group'
export type AccountSortableColumn = string
@@ -199,6 +199,7 @@ export interface AccountsViewUrlState {
columnDisplay?: AccountColumnDisplayState
tileFilter?: TileFilter
customProperties?: AccountFilter[]
+ filterGroups?: AccountFilter[][]
}
export type AccountsViewStateSource = 'defaults' | 'draft' | 'saved_view' | 'shared_url'
@@ -262,6 +263,9 @@ function accountsViewStateFromUrl(
tags: Array.isArray(view.tags) ? view.tags.filter((tag): tag is string => typeof tag === 'string') : [],
tileFilter: view.tileFilter && typeof view.tileFilter === 'object' ? view.tileFilter : null,
customProperties: Array.isArray(view.customProperties) ? view.customProperties : [],
+ filterGroups: Array.isArray(view.filterGroups)
+ ? view.filterGroups.filter((group): group is AccountFilter[] => Array.isArray(group))
+ : [],
},
tiles,
columnDisplay: view.columnDisplay && typeof view.columnDisplay === 'object' ? view.columnDisplay : {},
@@ -286,6 +290,7 @@ export interface accountsLogicValues {
mineOnly: boolean // customerAnalyticsSceneLogic
currentTeamId: number | null // teamLogic
user: UserType | null // userLogic
+ accountFilterGroups: AccountFilter[][]
accountFilters: AccountFilter[]
accountIdFilter: string | null
accountPresenceByAccountId: Record<string, AccountPresenceViewerApi[]>
@@ -466,6 +471,9 @@ export interface accountsLogicActions {
}
user: UserType | null
} // userLogic
+ addAccountFilterGroup: () => {
+ value: true
+ }
addTagToFilter: (tag: string) => {
tag: string
}
@@ -519,6 +527,12 @@ export interface accountsLogicActions {
refresh: () => {
value: true
}
+ removeAccountFilterGroup: (index: number) => {
+ index: number
+ }
+ removeFirstAccountFilterGroup: () => {
+ value: true
+ }
reportFilterChange: (filterType: AccountFilterType) => {
filterType: AccountFilterType
}
@@ -539,6 +553,9 @@ export interface accountsLogicActions {
accountId: string
column: string
}
+ setAccountFilterGroups: (groups: AccountFilter[][]) => {
+ groups: AccountFilter[][]
+ }
setAccountFilters: (filters: AccountFilter[]) => {
filters: AccountFilter[]
}
@@ -630,6 +647,13 @@ export interface accountsLogicActions {
definition: CustomPropertyDefinitionApi
value: boolean | number | string | null
}
+ updateAccountFilterGroup: (
+ index: number,
+ filters: AccountFilter[]
+ ) => {
+ filters: AccountFilter[]
+ index: number
+ }
updateAccountFilters: (filters: AccountFilter[]) => {
filters: AccountFilter[]
}
@@ -665,7 +689,8 @@ export interface accountsLogicMeta {
searchQuery: string,
tagsFilter: string[],
assignmentStatus: AssignmentStatus,
- accountFilters: AccountFilter[]
+ accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][]
) => number
viewState: (
selectColumns: string[],
@@ -677,6 +702,7 @@ export interface accountsLogicMeta {
tileFilter: TileFilter | null,
tiles: AccountsOverviewTile[],
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
columnDisplay: AccountColumnDisplayState
) => AccountsViewState
viewUrlState: (
@@ -689,6 +715,7 @@ export interface accountsLogicMeta {
defaultSelectColumns: string[],
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
columnDisplay: AccountColumnDisplayState
) => AccountsViewUrlState
listDatasetKey: (
@@ -700,6 +727,7 @@ export interface accountsLogicMeta {
accountIdFilter: string | null,
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
relationshipDefinitionsById: Record<string, AccountRelationshipDefinitionApi>,
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>
) => string
@@ -729,6 +757,7 @@ export interface accountsLogicMeta {
accountIdFilter: string | null,
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
relationshipDefinitionsById: Record<string, AccountRelationshipDefinitionApi>,
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
columnDisplay: AccountColumnDisplayState,
@@ -829,6 +858,11 @@ export const accountsLogic = kea<accountsLogicType>([
syncViewStateToUrl: true,
setTagsFilter: (tags: string[]) => ({ tags }),
setAccountFilters: (filters: AccountFilter[]) => ({ filters }),
+ setAccountFilterGroups: (groups: AccountFilter[][]) => ({ groups }),
+ addAccountFilterGroup: true,
+ removeFirstAccountFilterGroup: true,
+ removeAccountFilterGroup: (index: number) => ({ index }),
+ updateAccountFilterGroup: (index: number, filters: AccountFilter[]) => ({ index, filters }),
updateAccountFilters: (filters: AccountFilter[]) => ({ filters }),
setAssignmentStatus: (status: AssignmentStatus) => ({ status }),
setAssignedToFilter: (value: RoleFilterValue) => ({ value }),
@@ -914,6 +948,16 @@ export const accountsLogic = kea<accountsLogicType>([
setAccountFilters: (_, { filters }) => filters,
},
],
+ accountFilterGroups: [
+ [] as AccountFilter[][],
+ {
+ setAccountFilterGroups: (_, { groups }) => groups,
+ addAccountFilterGroup: (groups) => [...groups, []],
+ removeAccountFilterGroup: (groups, { index }) => groups.filter((_, groupIndex) => groupIndex !== index),
+ updateAccountFilterGroup: (groups, { index, filters }) =>
+ groups.map((group, groupIndex) => (groupIndex === index ? filters : group)),
+ },
+ ],
assignmentStatus: [
'all' as AssignmentStatus,
{
@@ -1082,18 +1126,19 @@ export const accountsLogic = kea<accountsLogicType>([
!!savingTags[accountId],
],
activeFilterCount: [
- (s) => [s.searchQuery, s.tagsFilter, s.assignmentStatus, s.accountFilters],
+ (s) => [s.searchQuery, s.tagsFilter, s.assignmentStatus, s.accountFilters, s.accountFilterGroups],
(
searchQuery: string,
tagsFilter: string[],
assignmentStatus: AssignmentStatus,
- accountFilters: AccountFilter[]
+ accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][]
): number =>
[
!!searchQuery.trim(),
tagsFilter.length > 0,
assignmentStatus !== 'all',
- accountFilters.length > 0,
+ accountFilters.length > 0 || accountFilterGroups.some((group) => group.length > 0),
].filter(Boolean).length,
],
viewState: [
@@ -1107,6 +1152,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.tileFilter,
s.tiles,
s.accountFilters,
+ s.accountFilterGroups,
s.columnDisplay,
],
(
@@ -1119,11 +1165,12 @@ export const accountsLogic = kea<accountsLogicType>([
tileFilter: TileFilter | null,
tiles: import('./accountsOverviewTilesLogic').AccountsOverviewTile[],
customProperties: AccountFilter[],
+ filterGroups: AccountFilter[][],
columnDisplay: AccountColumnDisplayState
): AccountsViewState => ({
columns,
sortOrder,
- filters: { search, assignmentStatus, assignedTo, tags, tileFilter, customProperties },
+ filters: { search, assignmentStatus, assignedTo, tags, tileFilter, customProperties, filterGroups },
tiles,
columnDisplay,
}),
@@ -1139,6 +1186,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.defaultSelectColumns,
s.tileFilter,
s.accountFilters,
+ s.accountFilterGroups,
s.columnDisplay,
],
(
@@ -1151,6 +1199,7 @@ export const accountsLogic = kea<accountsLogicType>([
defaultSelectColumns: string[],
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
columnDisplay: AccountColumnDisplayState
): AccountsViewUrlState => {
const state: AccountsViewUrlState = {}
@@ -1184,6 +1233,9 @@ export const accountsLogic = kea<accountsLogicType>([
if (accountFilters.length > 0) {
state.customProperties = accountFilters
}
+ if (accountFilterGroups.some((group) => group.length > 0)) {
+ state.filterGroups = accountFilterGroups.filter((group) => group.length > 0)
+ }
// Without an explicit status, a nonempty hash would restore as a legacy assigned-only view.
if (assignmentStatus === 'all' && Object.keys(state).length > 0) {
state.assignmentStatus = 'all'
@@ -1201,6 +1253,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.accountIdFilter,
s.tileFilter,
s.accountFilters,
+ s.accountFilterGroups,
s.relationshipDefinitionsById,
s.customPropertyDefinitionsById,
],
@@ -1213,6 +1266,7 @@ export const accountsLogic = kea<accountsLogicType>([
accountIdFilter: string | null,
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
relationshipDefinitionsById: Record<string, AccountRelationshipDefinitionApi>,
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>
): string =>
@@ -1224,6 +1278,7 @@ export const accountsLogic = kea<accountsLogicType>([
accountIdFilter,
tileFilter,
accountFilters,
+ accountFilterGroups,
relationshipDefinitionsById,
customPropertyDefinitionsById,
})}`,
@@ -1278,6 +1333,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.accountIdFilter,
s.tileFilter,
s.accountFilters,
+ s.accountFilterGroups,
s.relationshipDefinitionsById,
s.customPropertyDefinitionsById,
s.columnDisplay,
@@ -1293,6 +1349,7 @@ export const accountsLogic = kea<accountsLogicType>([
accountIdFilter: string | null,
tileFilter: TileFilter | null,
accountFilters: AccountFilter[],
+ accountFilterGroups: AccountFilter[][],
relationshipDefinitionsById: Record<string, AccountRelationshipDefinitionApi>,
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
columnDisplay: AccountColumnDisplayState,
@@ -1307,6 +1364,7 @@ export const accountsLogic = kea<accountsLogicType>([
accountIdFilter,
tileFilter,
accountFilters,
+ accountFilterGroups,
relationshipDefinitionsById,
customPropertyDefinitionsById,
columnDisplay,
@@ -1402,6 +1460,7 @@ export const accountsLogic = kea<accountsLogicType>([
viewState.filters.assignmentStatus === 'assigned' ? viewState.filters.assignedTo : []
)
actions.setAccountFilters(viewState.filters.customProperties)
+ actions.setAccountFilterGroups(viewState.filters.filterGroups)
actions.setSortOrder(viewState.sortOrder)
actions.setTiles(viewState.tiles)
actions.setTileFilter(viewState.filters.tileFilter)
@@ -1545,6 +1604,12 @@ export const accountsLogic = kea<accountsLogicType>([
if (!objectsEqual(supportedFilters, values.accountFilters)) {
actions.setAccountFilters(supportedFilters)
}
+ const supportedGroups = values.accountFilterGroups.map((group) =>
+ supportedAccountFilters(group, definitionsById, values.relationshipDefinitionsById)
+ )
+ if (!objectsEqual(supportedGroups, values.accountFilterGroups)) {
+ actions.setAccountFilterGroups(supportedGroups)
+ }
},
loadRelationshipDefinitionsSuccess: () => {
cache.relationshipDefinitionsLoaded = true
@@ -1559,10 +1624,60 @@ export const accountsLogic = kea<accountsLogicType>([
if (!objectsEqual(supportedFilters, values.accountFilters)) {
actions.setAccountFilters(supportedFilters)
}
+ const supportedGroups = values.accountFilterGroups.map((group) =>
+ supportedAccountFilters(group, values.customPropertyDefinitionsById, values.relationshipDefinitionsById)
+ )
+ if (!objectsEqual(supportedGroups, values.accountFilterGroups)) {
+ actions.setAccountFilterGroups(supportedGroups)
+ }
},
loadRelationshipDefinitionsFailure: () => {
cache.relationshipDefinitionsLoaded = true
actions.setAccountFilters(values.accountFilters)
+ if (!cache.customPropertyDefinitionsLoaded) {
+ return
+ }
+ const supportedGroups = values.accountFilterGroups.map((group) =>
+ supportedAccountFilters(group, values.customPropertyDefinitionsById, values.relationshipDefinitionsById)
+ )
+ if (!objectsEqual(supportedGroups, values.accountFilterGroups)) {
+ actions.setAccountFilterGroups(supportedGroups)
+ }
+ },
+ setAccountFilterGroups: ({ groups }) => {
+ if (cache.customPropertyDefinitionsLoaded && cache.relationshipDefinitionsLoaded) {
+ const supportedGroups = groups.map((group) =>
+ supportedAccountFilters(
+ group,
+ values.customPropertyDefinitionsById,
+ values.relationshipDefinitionsById
+ )
+ )
+ if (!objectsEqual(supportedGroups, groups)) {
+ actions.setAccountFilterGroups(supportedGroups)
+ return
+ }
+ }
+ persistViewStateAndUrl(actions, cache.applyingViewState, values.viewStateHydrated)
+ },
+ addAccountFilterGroup: () => {
+ persistViewStateAndUrl(actions, cache.applyingViewState, values.viewStateHydrated)
+ actions.reportFilterChange('or_group')
+ },
+ removeFirstAccountFilterGroup: () => {
+ const [first = [], ...remaining] = values.accountFilterGroups
+ actions.setAccountFilterGroups(remaining)
+ actions.setAccountFilters(first)
+ actions.reportFilterChange('or_group')
+ },
+ removeAccountFilterGroup: () => {
+ persistViewStateAndUrl(actions, cache.applyingViewState, values.viewStateHydrated)
+ actions.reportFilterChange('or_group')
+ },
+ updateAccountFilterGroup: () => {
+ persistViewStateAndUrl(actions, cache.applyingViewState, values.viewStateHydrated)
+ actions.setAccountFilterGroups(values.accountFilterGroups)
+ actions.reportFilterChange('or_group')
},
setAccountFilters: ({ filters }) => {
persistViewStateAndUrl(actions, cache.applyingViewState, values.viewStateHydrated)
@@ -1646,6 +1761,12 @@ export const accountsLogic = kea<accountsLogicType>([
properties.role_count = values.assignedToFilter.length
properties.is_cleared = values.assignedToFilter.length === 0
break
+ case 'or_group':
+ properties.group_count = values.accountFilterGroups.length + 1
+ properties.is_cleared =
+ values.accountFilters.length === 0 &&
+ values.accountFilterGroups.every((group) => group.length === 0)
+ break
}
posthog.capture(AccountsEvents.FilterChanged, properties)
},
@@ -1977,6 +2098,9 @@ export const accountsLogic = kea<accountsLogicType>([
if (values.accountFilters.length > 0) {
actions.setAccountFilters([])
}
+ if (values.accountFilterGroups.length > 0) {
+ actions.setAccountFilterGroups([])
+ }
const term = externalId || name
if (term) {
actions.setSearchQuery(term)
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
index 9b9c6177469f..f0605e48de67 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
@@ -18,6 +18,7 @@ import {
AccountsTableQueryPlan,
BuildAccountsTableQueryPlanInput,
accountsTableCell,
+ accountsTableDatasetKey,
buildAccountsTableQueryPlan,
} from './accountsTableQuery'
@@ -76,6 +77,7 @@ function queryInput(overrides: Partial<BuildAccountsTableQueryPlanInput> = {}):
accountIdFilter: null,
tileFilter: null,
accountFilters: [],
+ accountFilterGroups: [],
relationshipDefinitionsById: {
[RELATIONSHIP_ID]: { id: RELATIONSHIP_ID, name: 'CSM' } as AccountRelationshipDefinitionApi,
},
@@ -131,6 +133,48 @@ describe('accountsTableQuery', () => {
})
})
+ it('keeps global filters outside OR groups of supported property filters', () => {
+ const input = queryInput({
+ searchQuery: 'Account',
+ accountFilters: [relationshipFilter(), customFilter({ operator: PropertyOperator.IsNotSet, value: null })],
+ accountFilterGroups: [[customFilter({ operator: PropertyOperator.Exact, value: 20 })]],
+ })
+ const plan = buildAccountsTableQueryPlan(input)
+
+ expect(plan.query.filters).toEqual([{ kind: 'search', query: 'Account' }])
+ expect(plan.query.filterGroups).toEqual([
+ [
+ { kind: 'relationship', definitionId: RELATIONSHIP_ID, operator: 'exact', userIds: [7] },
+ { kind: 'custom_property', definitionId: CUSTOM_PROPERTY_ID, operator: 'is_not_set', values: [] },
+ ],
+ [{ kind: 'custom_property', definitionId: CUSTOM_PROPERTY_ID, operator: 'exact', values: [20] }],
+ ])
+ expect(accountsTableDatasetKey(input)).not.toEqual(
+ accountsTableDatasetKey({ ...input, accountFilterGroups: [[accountFieldFilter()]] })
+ )
+ })
+
+ it('keeps valid conditions when a restored group contains deleted properties', () => {
+ const validName = accountFieldFilter({
+ key: AccountsTableAccountField.Name,
+ operator: PropertyOperator.Exact,
+ value: 'Example',
+ })
+ const missingProperty = customFilter({ key: '99999999-9999-9999-9999-999999999999' })
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ accountFilters: [validName, missingProperty],
+ accountFilterGroups: [[relationshipFilter(), missingProperty], [missingProperty]],
+ })
+ )
+
+ expect(plan.query.filters).toEqual([])
+ expect(plan.query.filterGroups).toEqual([
+ [{ kind: 'account_field', field: AccountsTableAccountField.Name, operator: 'exact', values: ['Example'] }],
+ [{ kind: 'relationship', definitionId: RELATIONSHIP_ID, operator: 'exact', userIds: [7] }],
+ ])
+ })
+
it('translates typed native account field filters', () => {
const plan = buildAccountsTableQueryPlan(
queryInput({
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
index ef2385d4860b..970da90347ea 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
@@ -12,6 +12,7 @@ import {
AccountsTableCustomPropertyFilter,
AccountsTableCustomPropertyOperator,
AccountsTableFilter,
+ AccountsTablePropertyFilter,
AccountsTableRelationshipFilter,
AccountsTableRelationshipOperator,
AccountsTableQuery,
@@ -119,6 +120,7 @@ export interface AccountsTableDatasetInput {
accountIdFilter: string | null
tileFilter: TileFilter | null
accountFilters: AccountFilter[]
+ accountFilterGroups: AccountFilter[][]
relationshipDefinitionsById: Record<string, AccountRelationshipDefinitionApi>
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>
}
@@ -295,7 +297,27 @@ export function supportedAccountFilters(
)
}
-function queryFilters(input: AccountsTableDatasetInput): AccountsTableFilter[] {
+function queryPropertyFilter(
+ filter: AccountFilter,
+ input: AccountsTableDatasetInput
+): AccountsTablePropertyFilter | null {
+ return isAccountPropertyFilter(filter)
+ ? accountFieldFilter(filter)
+ : isAccountRelationshipFilter(filter)
+ ? relationshipFilter(filter, input.relationshipDefinitionsById)
+ : customPropertyFilter(filter, input.customPropertyDefinitionsById)
+}
+
+function queryPropertyFilterGroups(input: AccountsTableDatasetInput): AccountsTablePropertyFilter[][] {
+ return [input.accountFilters, ...input.accountFilterGroups]
+ .map((group) => group.map((filter) => queryPropertyFilter(filter, input)).filter((filter) => filter !== null))
+ .filter((group) => group.length > 0)
+}
+
+function queryFilters(
+ input: AccountsTableDatasetInput,
+ propertyGroups: AccountsTablePropertyFilter[][]
+): AccountsTableFilter[] {
if (input.accountIdFilter) {
return [{ kind: 'account_id', accountId: input.accountIdFilter } satisfies AccountsTableAccountIdFilter]
}
@@ -323,15 +345,8 @@ function queryFilters(input: AccountsTableDatasetInput): AccountsTableFilter[] {
filters.push({ kind: 'assigned' } satisfies AccountsTableAssignedFilter)
}
}
- for (const filter of input.accountFilters) {
- const translatedFilter = isAccountPropertyFilter(filter)
- ? accountFieldFilter(filter)
- : isAccountRelationshipFilter(filter)
- ? relationshipFilter(filter, input.relationshipDefinitionsById)
- : customPropertyFilter(filter, input.customPropertyDefinitionsById)
- if (translatedFilter) {
- filters.push(translatedFilter)
- }
+ if (propertyGroups.length === 1) {
+ filters.push(...propertyGroups[0])
}
if (input.tileFilter?.filter) {
const filter = input.tileFilter.filter
@@ -353,8 +368,10 @@ function queryFilters(input: AccountsTableDatasetInput): AccountsTableFilter[] {
export function accountsTableDatasetKey(input: AccountsTableDatasetInput): string {
const includeHiddenAccounts = input.accountIdFilter !== null
+ const propertyGroups = includeHiddenAccounts ? [] : queryPropertyFilterGroups(input)
return JSON.stringify({
- filters: queryFilters(input),
+ filters: queryFilters(input, propertyGroups),
+ filterGroups: propertyGroups.length > 1 ? propertyGroups : undefined,
includeChurned: includeHiddenAccounts,
includeIgnored: includeHiddenAccounts,
})
@@ -391,13 +408,15 @@ export function buildAccountsTableQueryPlan(input: BuildAccountsTableQueryPlanIn
}
}
- const filters = queryFilters(input)
+ const propertyGroups = input.accountIdFilter ? [] : queryPropertyFilterGroups(input)
+ const filters = queryFilters(input, propertyGroups)
return {
query: {
kind: NodeKind.AccountsTableQuery,
columns: columns.map(({ column }) => column),
filters,
+ filterGroups: propertyGroups.length > 1 ? propertyGroups : undefined,
includeChurned: input.accountIdFilter !== null,
includeIgnored: input.accountIdFilter !== null,
sort,
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
index e79a7732e67e..0da7c681682e 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
@@ -25,6 +25,7 @@ const draft: AccountsViewState = {
tags: [],
tileFilter: null,
customProperties: [],
+ filterGroups: [],
},
tiles: [...DEFAULT_TILES],
columnDisplay: {},
@@ -123,6 +124,17 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
values: [100],
},
},
+ filterGroups: [
+ [
+ {
+ type: PropertyFilterType.AccountCustomProperty as const,
+ key: '11111111-2222-3333-4444-555555555555',
+ operator: PropertyOperator.Exact,
+ value: 'Staged',
+ label: 'Tier',
+ },
+ ],
+ ],
customProperties: [
{
type: PropertyFilterType.Account as const,
@@ -163,6 +175,7 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
tags: [],
tileFilter: null,
customProperties: [],
+ filterGroups: [],
},
tiles: [...DEFAULT_TILES],
columnDisplay: {},
@@ -183,6 +196,7 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
tags: [],
tileFilter: null,
customProperties: [],
+ filterGroups: [],
})
expect(state.tiles).toEqual(DEFAULT_TILES)
expect(state.sortOrder).toBeNull()
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
index b18635eb0135..b031933ae32b 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
@@ -24,6 +24,7 @@ export interface AccountsViewFilters {
tags: string[]
tileFilter: TileFilter | null
customProperties: AccountFilter[]
+ filterGroups: AccountFilter[][]
}
interface AccountsViewFiltersRaw extends Partial<AccountsViewFilters> {
@@ -106,6 +107,9 @@ export function serializeAccountsView(state: AccountsViewState): AccountsViewPay
if (state.filters.customProperties.length > 0) {
filters.customProperties = state.filters.customProperties
}
+ if (state.filters.filterGroups.some((group) => group.length > 0)) {
+ filters.filterGroups = state.filters.filterGroups.filter((group) => group.length > 0)
+ }
const properties: AccountsViewProperties = { tiles: state.tiles }
if (Object.keys(state.columnDisplay).length > 0) {
properties.column_display = state.columnDisplay
@@ -161,6 +165,10 @@ const AccountsViewDraft = z.object({
})
.nullable(),
customProperties: z.array(z.object({}).passthrough()),
+ filterGroups: z
+ .array(z.array(z.object({}).passthrough()))
+ .optional()
+ .default([]),
}),
tiles: z.array(StoredTile),
columnDisplay: z.record(z.string(), z.object({ mode: z.enum(['sparkline', 'trend']), window_days: z.number() })),
@@ -214,6 +222,9 @@ export function deserializeAccountsView(view: Partial<ColumnConfigurationApi>):
tags: rawFilters.tags ?? [],
tileFilter: rawFilters.tileFilter ?? null,
customProperties: Array.isArray(rawFilters.customProperties) ? rawFilters.customProperties : [],
+ filterGroups: Array.isArray(rawFilters.filterGroups)
+ ? rawFilters.filterGroups.filter((group): group is AccountFilter[] => Array.isArray(group))
+ : [],
},
tiles: rawProperties.tiles && rawProperties.tiles.length > 0 ? rawProperties.tiles : [...DEFAULT_TILES],
columnDisplay:
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
index c08a88408fe4..3788b2308a4b 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
@@ -364,6 +364,7 @@ describe('accountsViewsLogic', () => {
tags: [],
tileFilter: null,
customProperties: [],
+ filterGroups: [],
},
tiles: [...DEFAULT_TILES],
columnDisplay: {},
diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.ts
index a5e71ac94d38..4c41a2434171 100644
--- a/products/customer_analytics/frontend/generated/api.schemas.ts
+++ b/products/customer_analytics/frontend/generated/api.schemas.ts
@@ -1388,55 +1388,6 @@ export interface AccountsTableCustomPropertyHistoryColumnApi {
windowDays: WindowDaysApi
}
-export interface AccountsTableSearchFilterApi {
- kind?: 'search'
- query: string
-}
-
-export interface AccountsTableTagsFilterApi {
- kind?: 'tags'
- /** Match accounts carrying any of these tag names. */
- tagNames: string[]
-}
-
-export interface AccountsTableAssignedToFilterApi {
- kind?: 'assigned_to'
- /** Match accounts where any listed user actively holds any relationship. */
- userIds: number[]
-}
-
-export const AccountsTableAssignedFilterApiValue = {
- kind: 'assigned',
-} as const
-export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
-
-export const AccountsTableUnassignedFilterApiValue = {
- kind: 'unassigned',
-} as const
-export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
-
-export type AccountsTableRelationshipOperatorApi =
- (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
-
-export const AccountsTableRelationshipOperatorApi = {
- Exact: 'exact',
- IsNot: 'is_not',
- IsSet: 'is_set',
- IsNotSet: 'is_not_set',
-} as const
-
-export interface AccountsTableRelationshipFilterApi {
- definitionId: string
- kind?: 'relationship'
- operator: AccountsTableRelationshipOperatorApi
- userIds?: number[] | null
-}
-
-export interface AccountsTableAccountIdFilterApi {
- accountId: string
- kind?: 'account_id'
-}
-
export type AccountsTableAccountFieldOperatorApi =
(typeof AccountsTableAccountFieldOperatorApi)[keyof typeof AccountsTableAccountFieldOperatorApi]
@@ -1459,6 +1410,23 @@ export interface AccountsTableAccountFieldFilterApi {
values?: string[] | null
}
+export type AccountsTableRelationshipOperatorApi =
+ (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
+
+export const AccountsTableRelationshipOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+} as const
+
+export interface AccountsTableRelationshipFilterApi {
+ definitionId: string
+ kind?: 'relationship'
+ operator: AccountsTableRelationshipOperatorApi
+ userIds?: number[] | null
+}
+
export type AccountsTableCustomPropertyOperatorApi =
(typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
@@ -1488,6 +1456,38 @@ export interface AccountsTableCustomPropertyFilterApi {
values?: (string | number | boolean)[] | null
}
+export interface AccountsTableSearchFilterApi {
+ kind?: 'search'
+ query: string
+}
+
+export interface AccountsTableTagsFilterApi {
+ kind?: 'tags'
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[]
+}
+
+export interface AccountsTableAssignedToFilterApi {
+ kind?: 'assigned_to'
+ /** Match accounts where any listed user actively holds any relationship. */
+ userIds: number[]
+}
+
+export const AccountsTableAssignedFilterApiValue = {
+ kind: 'assigned',
+} as const
+export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
+
+export const AccountsTableUnassignedFilterApiValue = {
+ kind: 'unassigned',
+} as const
+export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
+
+export interface AccountsTableAccountIdFilterApi {
+ accountId: string
+ kind?: 'account_id'
+}
+
export const AccountsTableCountMetricApiValue = {
kind: 'count',
} as const
@@ -2039,6 +2039,14 @@ export interface AccountsTableQueryApi {
| AccountsTableCustomPropertyColumnApi
| AccountsTableCustomPropertyHistoryColumnApi
)[]
+ /** Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply. */
+ filterGroups?:
+ | (
+ | AccountsTableAccountFieldFilterApi
+ | AccountsTableRelationshipFilterApi
+ | AccountsTableCustomPropertyFilterApi
+ )[][]
+ | null
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
filters?:
| (
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 2a503c1c8ef1..4dc0463ada1f 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -8578,55 +8578,6 @@ export interface AccountsTableCustomPropertyHistoryColumnApi {
windowDays: WindowDaysApi
}
-export interface AccountsTableSearchFilterApi {
- kind?: 'search'
- query: string
-}
-
-export interface AccountsTableTagsFilterApi {
- kind?: 'tags'
- /** Match accounts carrying any of these tag names. */
- tagNames: string[]
-}
-
-export interface AccountsTableAssignedToFilterApi {
- kind?: 'assigned_to'
- /** Match accounts where any listed user actively holds any relationship. */
- userIds: number[]
-}
-
-export const AccountsTableAssignedFilterApiValue = {
- kind: 'assigned',
-} as const
-export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
-
-export const AccountsTableUnassignedFilterApiValue = {
- kind: 'unassigned',
-} as const
-export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
-
-export type AccountsTableRelationshipOperatorApi =
- (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
-
-export const AccountsTableRelationshipOperatorApi = {
- Exact: 'exact',
- IsNot: 'is_not',
- IsSet: 'is_set',
- IsNotSet: 'is_not_set',
-} as const
-
-export interface AccountsTableRelationshipFilterApi {
- definitionId: string
- kind?: 'relationship'
- operator: AccountsTableRelationshipOperatorApi
- userIds?: number[] | null
-}
-
-export interface AccountsTableAccountIdFilterApi {
- accountId: string
- kind?: 'account_id'
-}
-
export type AccountsTableAccountFieldOperatorApi =
(typeof AccountsTableAccountFieldOperatorApi)[keyof typeof AccountsTableAccountFieldOperatorApi]
@@ -8649,6 +8600,23 @@ export interface AccountsTableAccountFieldFilterApi {
values?: string[] | null
}
+export type AccountsTableRelationshipOperatorApi =
+ (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
+
+export const AccountsTableRelationshipOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+} as const
+
+export interface AccountsTableRelationshipFilterApi {
+ definitionId: string
+ kind?: 'relationship'
+ operator: AccountsTableRelationshipOperatorApi
+ userIds?: number[] | null
+}
+
export type AccountsTableCustomPropertyOperatorApi =
(typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
@@ -8678,6 +8646,38 @@ export interface AccountsTableCustomPropertyFilterApi {
values?: (string | number | boolean)[] | null
}
+export interface AccountsTableSearchFilterApi {
+ kind?: 'search'
+ query: string
+}
+
+export interface AccountsTableTagsFilterApi {
+ kind?: 'tags'
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[]
+}
+
+export interface AccountsTableAssignedToFilterApi {
+ kind?: 'assigned_to'
+ /** Match accounts where any listed user actively holds any relationship. */
+ userIds: number[]
+}
+
+export const AccountsTableAssignedFilterApiValue = {
+ kind: 'assigned',
+} as const
+export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
+
+export const AccountsTableUnassignedFilterApiValue = {
+ kind: 'unassigned',
+} as const
+export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
+
+export interface AccountsTableAccountIdFilterApi {
+ accountId: string
+ kind?: 'account_id'
+}
+
export const AccountsTableCountMetricApiValue = {
kind: 'count',
} as const
@@ -8776,6 +8776,14 @@ export interface AccountsTableQueryApi {
| AccountsTableCustomPropertyColumnApi
| AccountsTableCustomPropertyHistoryColumnApi
)[]
+ /** Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply. */
+ filterGroups?:
+ | (
+ | AccountsTableAccountFieldFilterApi
+ | AccountsTableRelationshipFilterApi
+ | AccountsTableCustomPropertyFilterApi
+ )[][]
+ | null
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
filters?:
| (
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index acfc036a43fc..d7d19b74eda4 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -7635,55 +7635,6 @@ export interface AccountsTableCustomPropertyHistoryColumnApi {
windowDays: WindowDaysApi
}
-export interface AccountsTableSearchFilterApi {
- kind?: 'search'
- query: string
-}
-
-export interface AccountsTableTagsFilterApi {
- kind?: 'tags'
- /** Match accounts carrying any of these tag names. */
- tagNames: string[]
-}
-
-export interface AccountsTableAssignedToFilterApi {
- kind?: 'assigned_to'
- /** Match accounts where any listed user actively holds any relationship. */
- userIds: number[]
-}
-
-export const AccountsTableAssignedFilterApiValue = {
- kind: 'assigned',
-} as const
-export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
-
-export const AccountsTableUnassignedFilterApiValue = {
- kind: 'unassigned',
-} as const
-export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
-
-export type AccountsTableRelationshipOperatorApi =
- (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
-
-export const AccountsTableRelationshipOperatorApi = {
- Exact: 'exact',
- IsNot: 'is_not',
- IsSet: 'is_set',
- IsNotSet: 'is_not_set',
-} as const
-
-export interface AccountsTableRelationshipFilterApi {
- definitionId: string
- kind?: 'relationship'
- operator: AccountsTableRelationshipOperatorApi
- userIds?: number[] | null
-}
-
-export interface AccountsTableAccountIdFilterApi {
- accountId: string
- kind?: 'account_id'
-}
-
export type AccountsTableAccountFieldOperatorApi =
(typeof AccountsTableAccountFieldOperatorApi)[keyof typeof AccountsTableAccountFieldOperatorApi]
@@ -7706,6 +7657,23 @@ export interface AccountsTableAccountFieldFilterApi {
values?: string[] | null
}
+export type AccountsTableRelationshipOperatorApi =
+ (typeof AccountsTableRelationshipOperatorApi)[keyof typeof AccountsTableRelationshipOperatorApi]
+
+export const AccountsTableRelationshipOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+} as const
+
+export interface AccountsTableRelationshipFilterApi {
+ definitionId: string
+ kind?: 'relationship'
+ operator: AccountsTableRelationshipOperatorApi
+ userIds?: number[] | null
+}
+
export type AccountsTableCustomPropertyOperatorApi =
(typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
@@ -7735,6 +7703,38 @@ export interface AccountsTableCustomPropertyFilterApi {
values?: (string | number | boolean)[] | null
}
+export interface AccountsTableSearchFilterApi {
+ kind?: 'search'
+ query: string
+}
+
+export interface AccountsTableTagsFilterApi {
+ kind?: 'tags'
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[]
+}
+
+export interface AccountsTableAssignedToFilterApi {
+ kind?: 'assigned_to'
+ /** Match accounts where any listed user actively holds any relationship. */
+ userIds: number[]
+}
+
+export const AccountsTableAssignedFilterApiValue = {
+ kind: 'assigned',
+} as const
+export type AccountsTableAssignedFilterApi = typeof AccountsTableAssignedFilterApiValue
+
+export const AccountsTableUnassignedFilterApiValue = {
+ kind: 'unassigned',
+} as const
+export type AccountsTableUnassignedFilterApi = typeof AccountsTableUnassignedFilterApiValue
+
+export interface AccountsTableAccountIdFilterApi {
+ accountId: string
+ kind?: 'account_id'
+}
+
export const AccountsTableCountMetricApiValue = {
kind: 'count',
} as const
@@ -7833,6 +7833,14 @@ export interface AccountsTableQueryApi {
| AccountsTableCustomPropertyColumnApi
| AccountsTableCustomPropertyHistoryColumnApi
)[]
+ /** Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply. */
+ filterGroups?:
+ | (
+ | AccountsTableAccountFieldFilterApi
+ | AccountsTableRelationshipFilterApi
+ | AccountsTableCustomPropertyFilterApi
+ )[][]
+ | null
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
filters?:
| (
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f2a2ef824f1d..bef25bc82a62 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -2277,22 +2277,6 @@ export namespace Schemas {
kind?: 'relationship';
}
- export interface AccountsTableSearchFilter {
- kind?: 'search';
- query: string;
- }
-
- export interface AccountsTableTagsFilter {
- kind?: 'tags';
- /** Match accounts carrying any of these tag names. */
- tagNames: string[];
- }
-
- export const AccountsTableUnassignedFilterValue = {
- kind: 'unassigned',
- } as const;
- export type AccountsTableUnassignedFilter = typeof AccountsTableUnassignedFilterValue;
-
export type AccountsTableRelationshipOperator = typeof AccountsTableRelationshipOperator[keyof typeof AccountsTableRelationshipOperator];
@@ -2310,6 +2294,22 @@ export namespace Schemas {
userIds?: number[] | null;
}
+ export interface AccountsTableSearchFilter {
+ kind?: 'search';
+ query: string;
+ }
+
+ export interface AccountsTableTagsFilter {
+ kind?: 'tags';
+ /** Match accounts carrying any of these tag names. */
+ tagNames: string[];
+ }
+
+ export const AccountsTableUnassignedFilterValue = {
+ kind: 'unassigned',
+ } as const;
+ export type AccountsTableUnassignedFilter = typeof AccountsTableUnassignedFilterValue;
+
/**
* Requested direct Account fields, keyed by their typed field reference.
*/
@@ -2395,6 +2395,8 @@ export namespace Schemas {
export interface AccountsTableQuery {
/** Columns to load for each account. Account identity fields are always returned. */
columns: (AccountsTableAccountFieldColumn | AccountsTableTagsColumn | AccountsTableNoteCountColumn | AccountsTableRelationshipColumn | AccountsTableCustomPropertyColumn | AccountsTableCustomPropertyHistoryColumn)[];
+ /** Nonempty property-filter groups are ORed together; filters within each group use AND. Global filters still apply. */
+ filterGroups?: ((AccountsTableAccountFieldFilter | AccountsTableRelationshipFilter | AccountsTableCustomPropertyFilter)[])[] | null;
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
filters?: (AccountsTableSearchFilter | AccountsTableTagsFilter | AccountsTableAssignedToFilter | AccountsTableAssignedFilter | AccountsTableUnassignedFilter | AccountsTableRelationshipFilter | AccountsTableAccountIdFilter | AccountsTableAccountFieldFilter | AccountsTableCustomPropertyFilter)[] | null;
/** Include churned accounts. Churned accounts are hidden by default. */