PM-4777: Fixed select All in status dropdown#1720
PM-4777: Fixed select All in status dropdown#1720Harshitchudasama wants to merge 3 commits intodevfrom
Conversation
| const hasSelectedStatusFilter = (filters.status?.length ?? 0) > 0 | ||
| const appliedFilters = React.useMemo<Record<string, string[]>>(() => { | ||
| // const hasSelectedStatusFilter = (filters.status?.length ?? 0) > 0 | ||
| const hasSelectedStatusFilter = (filters.status?.length ?? 0) > 0 && filters.status?.[0] !== 'all' |
There was a problem hiding this comment.
Leftover commented code?
| const hasSelectedStatusFilter = (filters.status?.length ?? 0) > 0 && filters.status?.[0] !== 'all' | ||
|
|
||
| /* const appliedFilters = React.useMemo<Record<string, string[]>>(() => { | ||
| if (!restrictedCategory) { |
| ) | ||
| const selectedValueOverrides = React.useMemo<Record<string, string>>(() => { | ||
| /* const selectedValueOverrides = React.useMemo<Record<string, string>>(() => { | ||
| if (!restrictedCategory) { |
| // Reflect the user's explicit status choice in the dropdown display. | ||
| // Do not inject restrictedDefaultStatus here — it applies to the API query | ||
| // via appliedFilters but must not override the dropdown's "All" default. | ||
| const statusOverride = filters.status?.[0] !== 'all' ? filters.status?.[0] : undefined |
There was a problem hiding this comment.
🟡 Status dropdown shows "All" while API silently filters by ON_HOLD_ADMIN for restricted approver views
For engagement payment approvers (restricted view), the status dropdown now displays "All" on initial load and when the user explicitly selects "All", but the API query actually filters by ON_HOLD_ADMIN via appliedFilters (line 212). This is a regression from the pre-PR behavior where the dropdown correctly displayed "On Hold (Admin)" matching the actual API filter.
Mechanism of the mismatch
Pre-PR, selectedValueOverrides at line 229 used filters.status?.[0] ?? restrictedDefaultStatus, which defaulted to 'ON_HOLD_ADMIN' — the dropdown accurately reflected the API filter. Post-PR, this was changed to filters.status?.[0] !== 'all' ? filters.status?.[0] : undefined, which evaluates to undefined when filters.status is unset (initial state) or ['all'] (user selected All). Since statusOverride is undefined, no status key is added to selectedValueOverrides. Meanwhile defaultDropdownValues (line 245) sets status: 'all' unconditionally. The merged prop {...defaultDropdownValues, ...selectedValueOverrides} at line 575 passes status: 'all' to the FilterBar, so the dropdown displays "All". But appliedFilters (lines 210-212) still applies restrictedDefaultStatus (ON_HOLD_ADMIN) whenever hasSelectedStatusFilter is false.
This means: user sees "All" → expects all statuses → only sees ON_HOLD_ADMIN results. If they select "Owed", see results, then select "All" expecting to see everything including those Owed payments, they only get ON_HOLD_ADMIN.
Prompt for agents
The root cause is in selectedValueOverrides (line 229) and defaultDropdownValues (line 245). When filters.status is undefined or ['all'] in the restricted approver view, the dropdown shows 'All' but appliedFilters (line 210-212) still sends ON_HOLD_ADMIN to the API.
Two possible fixes depending on the desired UX:
1. If 'All' should truly mean 'all statuses' for restricted approvers: update appliedFilters to NOT inject restrictedDefaultStatus when the user explicitly selects 'All'. This means distinguishing between 'user has not touched the dropdown yet' (apply default) vs 'user chose All' (no status filter). One approach: only apply restrictedDefaultStatus when filters.status is undefined (initial state), but not when it is ['all'] (explicit selection).
2. If ON_HOLD_ADMIN should remain the default and 'All' was never intended to show all statuses: revert the dropdown display for restricted views to show 'ON_HOLD_ADMIN' when no explicit status is chosen. This could be done by restoring the old fallback logic: const statusOverride = filters.status?.[0] ?? restrictedDefaultStatus in selectedValueOverrides, and keeping defaultDropdownValues.status inside the if (!restrictedCategory) block so it doesn't override the restricted view's display.
Was this helpful? React with 👍 or 👎 to provide feedback.
Related JIRA Ticket:
https://topcoder.atlassian.net/browse/
What's in this PR?
PM-4777: Fixed select All in status dropdown