Skip to content

fix: add explicit None option to rule selection pickers#90914

Merged
MariaHCD merged 9 commits into
Expensify:mainfrom
aswin-s:fix/89536-add-none-option-rule-selection
Jun 2, 2026
Merged

fix: add explicit None option to rule selection pickers#90914
MariaHCD merged 9 commits into
Expensify:mainfrom
aswin-s:fix/89536-add-none-option-rule-selection

Conversation

@aswin-s

@aswin-s aswin-s commented May 17, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When editing a merchant rule (tag, category, or tax), users had no explicit way to clear a previously selected value. The only method was clicking the selected option again, which was undiscoverable.

This PR adds an explicit "None" option to the SearchSingleSelectionPicker component, gated behind a new allowNoneOption prop. When enabled, a localized "None" item appears in the selection list after the currently selected item, allowing users to clear their selection with a single tap. The onSelectItem guard is also updated from !item.value to item.value === undefined so the empty-string value of the None sentinel is not silently dropped.

RuleSelectionBase passes allowNoneOption to enable this for all six rule selection pages (AddTagPage, AddCategoryPage, AddTaxPage in both MerchantRules and settings/Rules). Other callers like SearchFiltersCurrencyBase are unaffected since the prop defaults to false.

Fixed Issues

$ #89536
PROPOSAL: #89536 (comment)

Tests

  1. Go to Workspace Settings → Rules → Merchant Rules
  2. Create or edit a rule and select a tag
  3. Verify a "None" option appears after the selected tag in the list
  4. Tap "None" and verify the tag selection is cleared
  5. Repeat the above for Category and Tax rule selections
  6. Verify the "None" option is filterable via the search input
  7. Open Search filters → Currency and verify no "None" option appears
  • Verify that no errors appear in the JS console

Offline tests

  1. Disconnect from the network
  2. Go to Workspace Settings → Rules → Merchant Rules
  3. Edit a rule and tap "None" to clear a tag selection
  4. Verify the update is applied optimistically
  5. Reconnect and verify the change persists

QA Steps

  1. Go to Workspace Settings → Rules → Merchant Rules
  2. Create or edit a rule and select a tag
  3. Verify a "None" option appears after the selected tag
  4. Tap "None" and verify the selection is cleared
  5. Repeat for Category and Tax selections
  6. Open Search filters → Currency and verify no "None" option appears
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android-native.mp4
Android: mWeb Chrome
android-web.mp4
iOS: Native
ios-native.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
MacOS.mp4

aswin-s added 2 commits May 17, 2026 20:54
Place the None option after the currently selected item to preserve
the focused/highlighted state and scroll position of the selected item.
@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 93.84% <ø> (ø)
src/components/Rule/RuleSelectionBase.tsx 0.00% <ø> (ø)
.../components/Search/SearchSingleSelectionPicker.tsx 91.66% <100.00%> (+91.66%) ⬆️
... and 12 files with indirect coverage changes

@aswin-s
aswin-s marked this pull request as ready for review May 18, 2026 03:56
@aswin-s
aswin-s requested review from a team as code owners May 18, 2026 03:56
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and rojiphil and removed request for a team May 18, 2026 03:56
@melvin-bot

melvin-bot Bot commented May 18, 2026

Copy link
Copy Markdown

@rojiphil Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team May 18, 2026 03:56
initiallySelectedItem: undefined,
});

const noneItem = screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}__none_option__`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❌ CONSISTENCY-2 (docs)

The string '__none_option__' is a magic value duplicated from the NONE_OPTION_KEY constant defined in SearchSingleSelectionPicker.tsx. If the constant value changes, this test will silently break.

Export NONE_OPTION_KEY from SearchSingleSelectionPicker.tsx and import it in the test:

import SearchSingleSelectionPicker, { NONE_OPTION_KEY } from '@components/Search/SearchSingleSelectionPicker';

// Then use it:
const noneItem = screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}${NONE_OPTION_KEY}`);

Reviewed at: 28bdbe6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28bdbe66ce

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +55 to +56
keyForList: NONE_OPTION_KEY,
isSelected: !selectedItem?.value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a collision-proof key for the synthetic None row

The synthetic option uses a hard-coded keyForList (__none_option__), but regular rows also use item.value as keyForList; in rule pickers those values come from user/workspace data. If a category/tag/tax identifier equals __none_option__, the list will contain duplicate keys/IDs for two different rows, which can cause incorrect row reconciliation/selection behavior and ambiguous testID targeting. Use a reserved key that cannot collide with user data (or derive a guaranteed-unique internal key) for the synthetic row.

Useful? React with 👍 / 👎.

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, good change!

aswin-s added 2 commits May 19, 2026 09:20
- Change NONE_OPTION_KEY to use null byte prefix, preventing collisions
  with user-created category/tag/tax identifiers
- Export NONE_OPTION_KEY and import it in tests instead of duplicating
  the magic string

@rojiphil rojiphil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @aswin-s for the PR. Code changes LGTM, but I have just left a NAB comment. Please have a look.

Comment thread src/components/Search/SearchSingleSelectionPicker.tsx Outdated
@rojiphil

Copy link
Copy Markdown
Contributor

@Expensify/design When there is a selected item, which one should have the priority to be at the top - selected Item or None?

90914-query-001.mp4

@shawnborton

shawnborton commented May 25, 2026

Copy link
Copy Markdown
Contributor

When there is a selected item, which one should have the priority to be at the top

Hmm I think @mkhutornyi is working on this but I thought the idea was:

  • if the list only has less than 12 options, do not move the selected item to the top
  • if the list has 12 or more options, always put the selected item at the very top

So then in the case of the list having 12 or more options, I would think None would show up after the selected rows. Definitely curious what the rest of @Expensify/design is thinking though, I don't feel strongly here.

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

Yeah that sounds right to me. The details being that it doesn't move to the top when it's clicked, but moves to the top when you come back into the menu. So on the actual selection it stays in place, right?

@shawnborton

Copy link
Copy Markdown
Contributor

Yup exactly!

@dannymcclain

Copy link
Copy Markdown
Contributor

Yup that sounds good to me too 👍

@aswin-s

aswin-s commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@rojiphil Addressed the NAB comment. Moved NONE_OPTION_KEY to CONST.SEARCH and updated all usages accordingly. Also merged latest main.

Regarding the position of the None option: the current implementation already matches the design expectation.

@aswin-s
aswin-s requested a review from rojiphil May 30, 2026 03:38
@rojiphil

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
90914-android-hybrid-001.mp4
Android: mWeb Chrome
90914-mweb-chrome-001.mp4
iOS: HybridApp
90914-ios-hybrid-001.mp4
iOS: mWeb Safari
90914-mweb-safari-001.mp4
MacOS: Chrome / Safari
90914-web-chrome-001.mp4

@rojiphil rojiphil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @aswin-s for the PR

@MariaHCD Changes LGTM and works well.
Approving for your review. Thanks.

@melvin-bot
melvin-bot Bot requested a review from MariaHCD May 30, 2026 05:28
@MariaHCD
MariaHCD requested a review from shawnborton June 1, 2026 15:17
@MariaHCD

MariaHCD commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Tagging @shawnborton for design review

@shawnborton

shawnborton commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Generally looks good to me.

One comment though - are you changing the behavior of what and when we put a selected item at the top of a list? If I recall, I think we decided that we always want the selected item to float to the top of the list ONLY IF the list is long enough to scroll off of the page. Or maybe ONLY IF we have greater than or equal to X number of items.

That might be something we're handling elsewhere, but just wanted to call it out. Otherwise this situation gets a bit odd:
CleanShot 2026-06-01 at 17 21 05@2x

cc @Expensify/design in case you have thoughts on that

@rojiphil

rojiphil commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

That might be something we're handling elsewhere, but just wanted to call it out.

Yeah @shawnborton. That seems to be addressed somewhere else as you had mentioned in #90914 (comment).
The implementation in this PR is focused on adding the none option.

@dannymcclain

Copy link
Copy Markdown
Contributor

in case you have thoughts on that

Oh I definitely do haha, but it sounds like it's being handled elsewhere 👍

The implementation in this PR is focused on adding the none option.

The None option is looking good to me though.

@shawnborton

Copy link
Copy Markdown
Contributor

Okay sounds good to me! cc @mkhutornyi for visibility

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

Agree with everything said by Danny and Shawn. Looking good otherwise 👍

@MariaHCD
MariaHCD merged commit 07fff58 into Expensify:main Jun 2, 2026
37 of 38 checks passed
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🚧 @MariaHCD has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

OSBotify commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MariaHCD in version: 9.3.97-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — docs update required

Yes — this PR introduces user-facing behavior that wasn't documented. Adding the None option lets users clear a previously selected Category, Tag, or Tax value when configuring a rule, and since allowNoneOption is enabled on the shared RuleSelectionBase, it appears in two documented flows:

Neither article previously explained how to clear a field value, so I added a concise FAQ entry to each.

Draft help site PR: #92456

UI labels were verified against src/languages/en.ts — the option label is None (common.none) and the save button is Save rule.

Note

I couldn't set you as the assignee on the draft PR — GitHub only allows assigning users with write access or who have commented on that PR. Please self-assign (or comment once and I can retry). The HelpDot label is applied.

@aswin-s, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

OSBotify commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.3.97-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

truph01 pushed a commit to truph01/App that referenced this pull request Jun 9, 2026
Adds FAQ entries to Workspace Merchant Rules and Personal Expense Rules
explaining how to clear a Category, Tag, or Tax value using the new None
option, reflecting Expensify#90914.

Co-authored-by: Aswin S <aswin-s@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants