Skip to content

[WOOMOB-2449] Fix attendance status filter to be single-select#15504

Merged
AdamGrzybkowski merged 4 commits intotrunkfrom
issue/woomob-2449-fix-attendance-filter
Mar 11, 2026
Merged

[WOOMOB-2449] Fix attendance status filter to be single-select#15504
AdamGrzybkowski merged 4 commits intotrunkfrom
issue/woomob-2449-fix-attendance-filter

Conversation

@AdamGrzybkowski
Copy link
Copy Markdown
Contributor

@AdamGrzybkowski AdamGrzybkowski commented Mar 10, 2026

Description

Fixes WOOMOB-2449

The attendance status filter in the bookings list allowed multi-select, which caused a 400 API error when multiple statuses were sent (attendance_status is not of type string). This PR makes the filter single-select so only one attendance status (or "Any") can be active at a time.

Changes:

  • Changed BookingAttendanceStatusFilterUiState to hold a single AttendanceStatus? instead of a Set
  • Simplified the ViewModel selection logic to replace (not toggle) the selected status
  • Updated BookingFilterRepository to read only the first stored value from DataStore (backwards compatible with previously stored multi-value data)
  • Simplified API serialization in BookingsRestClient to send a plain string

Note: I've decided to keep AttendanceStatuses since it's heavily used and in case we need to add multiselect again, it should be significanlty easier.

Test Steps

  1. Open the Bookings list
  2. Tap the filter icon and navigate to the Attendance Status filter
  3. Select "Attended" — verify the checkmark appears next to "Attended" only
  4. Select "Unattended" — verify "Attended" is deselected and "Unattended" is now selected
  5. Tap "Unattended" again — verify it stays selected (no toggle-off)
  6. Select "Any" — verify the filter is cleared
  7. Tap "Show Bookings" — verify no API error occurs

Images/gif

Screen_recording_20260310_110701.mp4
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses WOOMOB-2449 by changing the Bookings “Attendance status” filter from multi-select to single-select to prevent invalid API requests (attendance_status must be a single string).

Changes:

  • Updated attendance status UI state + ViewModel to track a single selected status (or “Any”).
  • Adjusted filter persistence to read only one stored status for backward compatibility with legacy multi-select data.
  • Updated REST query serialization to send a single attendance_status value.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/bookings/BookingsRestClient.kt Serializes attendance_status as a single string instead of a comma-separated list.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/data/BookingFilterRepository.kt Reads only one stored attendance status from DataStore for backward compatibility.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/attendancestatus/BookingAttendanceStatusFilterViewModel.kt Enforces single-select selection behavior and emits a single-value filter set.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/attendancestatus/BookingAttendanceStatusFilterUiState.kt Replaces selectedStatuses set with a single selectedStatus for UI rendering.
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/bookings/filter/attendancestatus/BookingAttendanceStatusFilterViewModelTest.kt Adds unit tests validating single-select behavior (including “Any” and no toggle-off).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 10, 2026

App Icon📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Build Number734
Version24.3-rc-3
Application IDcom.woocommerce.android.prealpha
Commitbc0ab39
Installation URL6b9foo1e7u3jg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 69.76744% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.57%. Comparing base (e7491b8) to head (bc0ab39).
⚠️ Report is 3 commits behind head on trunk.

Files with missing lines Patch % Lines
...ui/bookings/filter/data/BookingFilterRepository.kt 65.00% 4 Missing and 3 partials ⚠️
...press/android/fluxc/persistence/dao/BookingsDao.kt 0.00% 3 Missing ⚠️
...d/ui/bookings/filter/BookingFilterListViewModel.kt 0.00% 0 Missing and 1 partial ⚠️
...endancestatus/BookingAttendanceStatusFilterPage.kt 0.00% 1 Missing ⚠️
...twork/rest/wpcom/wc/bookings/BookingsRestClient.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15504      +/-   ##
============================================
+ Coverage     39.54%   39.57%   +0.02%     
- Complexity    11237    11248      +11     
============================================
  Files          2251     2251              
  Lines        129761   129749      -12     
  Branches      18170    18175       +5     
============================================
+ Hits          51316    51347      +31     
+ Misses        73207    73162      -45     
- Partials       5238     5240       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hichamboushaba hichamboushaba self-assigned this Mar 11, 2026
Copy link
Copy Markdown
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @AdamGrzybkowski, I'm approving, I left a single comment, but it's not a blocker, you can ignore it if you don't agree.

set(
"attendance_status",
attendanceStatuses.values.joinToString(FILTER_QUERY_PARAMETER_SEPERATOR) { it.key })
attendanceStatuses.values.singleOrNull()?.let {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I've decided to keep AttendanceStatuses since it's heavily used and in case we need to add multiselect again, it should be significanlty easier.

I believe it's unlikely we will have more attendance statuses than the two we currently have, as they are logically the only valid options. From a YAGNI perspective, I would also suggest changing attendanceStatuses to a single value in the networking layer to make the code easier to understand.

If, in the unlikely event, we do add more attendance statuses and the API supports multi-select options, we can reintroduce the logic. I think that would be a simple change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was 50/50 on that. Done in e7b0d80

@AdamGrzybkowski AdamGrzybkowski force-pushed the issue/woomob-2449-fix-attendance-filter branch from fc3878b to ff38406 Compare March 11, 2026 12:15
The booking attendance status filter allowed multi-select, causing
a 400 API error when multiple statuses were sent. Changed the UI
state and ViewModel to single-select, updated the DataStore reader
to only use the first stored value for backwards compatibility, and
simplified the API serialization to send a plain string.
Address review: replace firstOrNull with singleOrNull so that
legacy multi-value data is treated as unfiltered rather than
picking an arbitrary status. Update existing repository test
to save a single status.
Refactor the Set-based AttendanceStatuses wrapper to a single nullable
AttendanceStatus value across networking, persistence, and UI layers.
Since attendance status is mutually exclusive (attended/unattended), a
Set adds unnecessary complexity. Simplifies DAO query from IN clause to
nullable equality comparison and updates DataStore persistence with
legacy migration support.
Copy link
Copy Markdown
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work.

@AdamGrzybkowski AdamGrzybkowski force-pushed the issue/woomob-2449-fix-attendance-filter branch from e7b0d80 to bc0ab39 Compare March 11, 2026 17:26
@AdamGrzybkowski AdamGrzybkowski merged commit e7e2c35 into trunk Mar 11, 2026
16 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the issue/woomob-2449-fix-attendance-filter branch March 11, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants