feat: add activeFilters validator to DataTableProvider for filter segment validation #27208
+612
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a scalable solution for handling stale filter segment data by validating filters at the caller level when segments are applied.
Background: Filter segments store activeFilters as generic JSON. When referenced entities (users, event types, teams) are removed, the filter data becomes stale. Rather than coupling entity deletion logic with filter segment updates (as attempted in #26506), this PR validates filters at the point of consumption.
Changes:
validateActiveFiltersprop toDataTableProviderthat filters out invalid values when a segment is applieduseActiveFiltersValidatorhook in bookings module that validates userId, eventTypeId, and teamId filters against accessible resourcesRelated to #26506 (alternative approach)
Updates since last revision
"loading"state while data is fetchingisValidatorPendingin context so consumers can disable data fetching while waitingaccessibleEventTypeIdsto ensurenumber[]typeMandatory Tasks (DO NOT REMOVE)
How should this be tested?
Test configuration: 16 unit tests are included covering all validation scenarios.
Human Review Checklist
setSegmentIdcalls state setters before settingpendingSegmentRef, ensuring a re-render occurs soisValidatorPendingupdates correctlyisValidatorPendingcomputation (validateActiveFilters === "loading" && pendingSegmentRef.current !== null) correctly gates the bookings queryisValidatorReadychanges from false to trueas numbertype casts in validation logic are safe for the expected filter value types (userId, eventTypeId, teamId are always numbers).filter((v): v is number => typeof v === "number")for eventTypeIds doesn't accidentally filter out valid IDsLink to Devin run: https://app.devin.ai/sessions/7b7fa2f9d6bb48e98182ab873b5f0557
Requested by: @eunjae-lee