Skip to content

[Due for payment 2026-11-11] [$175] Add a Create "<search>" category row when an admin's category search returns no results #105298

Closed

Description

@JmillsExpensify

Background

When a workspace admin creates or edits an expense and opens the Category picker, a gray + at the top right lets them create a new category. When they search for a category that doesn't exist, the picker only shows No results found. Nothing on the page connects that dead end to the +.

We saw this exact issue recently in a new-user onboarding session. The admin sign-up wanted to categorize an expense as Training, searched for it, got no results, and had no clear next step. At that point the admin has already told us the exact category name they want, so we can offer to create it in one tap.

Product and design details

Create expense > Category picker, Training searched, No results found with Create "Training" category row below

Image

Basics

The row appears in any expense Category picker that already shows the gray +, so we are not introducing a new permission rule. In practice that's:

  • Creating an expense.
  • Editing an expense's category.

Users who don't see the + (e.g. non-admin members) see today's No results found with no row.

Trigger

We show the row only when the search returns zero results. <search> is the search string as typed, with leading and trailing spaces removed. We keep the user's capitalization. When the search matches one or more categories, even partially, we show the matches as today and no create row.

We also don't show the row when the search string can't be a category name, so the user only sees No results found, as today. That's when the string:

  • Is a reserved name: Uncategorized or ###.
  • Contains HTML tags, e.g. <b>.
  • Is longer than 255 characters.

These match the rules on the existing new-category page, so the row never offers an option that validation would reject.

Creating the category

Tapping the row:

  1. Creates a new, enabled category on the expense's workspace, named with the search string.
  2. Selects that category on the expense.
  3. Closes the picker and returns the user to the page they came from (e.g. Create expense confirmation), with Category filled in.

We reuse the existing category-creation behavior used by the +, including how it works offline. There's no confirmation step and no intermediate create page, because the user has already typed the name.

Disabled category with the same name

The picker hides disabled categories, so a search can return zero results even though the workspace already has a disabled category with that exact name. Creating it would fail as a duplicate. In this case, tapping the row turns the existing category back on and selects it on the expense instead of creating a new one.

Loading and empty states

No new loading or empty state. The row appears with No results found and updates as the user types.

Issue OwnerCurrent Issue Owner: @JS00001
Upwork Automation - Do Not Edit

Activity

  1. added
    ImprovementItem broken or needs improvement.
    InternalRequires API changes or must be handled by Expensify staff
    on Oct 28, 2026
  2. Krishna2323 commented on Oct 30, 2026

    @Krishna2323
    Contributor

    @MelvinBot prepare a proposal

  3. MelvinBot commented on Oct 30, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When an admin searches the expense Category picker and nothing matches, the picker shows only No results found. It gives them no way to create the category they just typed.

    What is the root cause of that problem?

    This is a new feature, not a bug. CategoryPicker owns the search text, and on zero results it only sets a header message (getHeaderMessageForNonUserList). It has no row or callback that turns the search text into a new category. Creating a category is only possible through the separate + page (DynamicIOURequestStepCategoryCreate.tsx:138-198).

    What changes do you think we should make in order to solve the problem?

    1. Add an opt-in prop to CategoryPicker, for example onCreateCategory?: (name: string) => void.

      • Show the row only when all of these are true: the prop is set, the trimmed search is non-empty, there are zero matching rows, and either getCategoryNameError(policyCategories, name) returns nothing or a disabled category has the exact same name.
      • Add the row as an extra one-item section: Plus icon, text from a new Create "<name>" category translation in every language file.
      • Build the header message from the real matches, so No results found still shows above the row.
      • Send that row's selection to onCreateCategory instead of onSubmit.
    2. Pass the prop only where the + shows today. Both places already check canCreateCategoryInSitu, so no new permission rule is needed:

      Every other CategoryPicker use stays unchanged: workspace rules, default category, search bulk edit, table cells and debug.

    3. Extract a shared hook, for example useCreateCategoryAndApplyToTransaction, from the create page's logic. The create page and both pickers use the hook. On tap it:

      • re-enables the category with setWorkspaceCategoryEnabled if a disabled one with the same decoded name exists
      • otherwise calls createPolicyCategory with the same onboarding and review-task data the create page passes
      • selects the category on the expense through the existing three-way branch (split draft, existing expense, or new draft). It passes policy categories that already include the new or re-enabled entry, so violations are correct.
      • closes the picker and goes back to the previous page (Navigation.goBack(basePath) / dismiss the modal)

      Both actions use API.write, so this works offline the same way the + flow does.

    4. Tests: add unit tests for when the row shows. Cover a valid name, a reserved name, HTML, more than 255 characters, a partial match, a disabled duplicate, and a user who can't see the +.

    Code references

    What alternative solutions did you explore? (Optional)

    • Open the existing create page pre-filled with the name. This is simpler, but it adds the confirmation step the issue rules out.
    • Show a button in listEmptyContent. It renders outside the list, so you can't reach it with the keyboard.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105298) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. Krishna2323 commented on Nov 1, 2026

    @Krishna2323
    Contributor

    @MelvinBot please update the proposal:

    1. Don't add a new hook that copies the split draft / existing expense / new draft branch. Extend useUpdateTransactionCategory instead, for example with an optional policyCategories argument on updateCategory so it sees the new category. The new hook should only create or re-enable the category, then call updateCategory.
    2. After tapping the row, use the same navigation as updateCategory in DynamicIOURequestStepCategory.tsx, including the CATEGORIZE branch that goes forward to Confirmation. Use backPath, not basePath.
    3. Add the new translation to en.ts only. The other language files are generated.
    4. Use StringUtils.sanitizeName for the row text, the validity check and the created name.
    5. Add tests for the tap itself: a disabled category with the same name gets turned back on, not created again, and the expense gets the category.
  5. MelvinBot commented on Nov 1, 2026

    @MelvinBot
    Contributor

    Proposal (updated)

    Updated based on feedback from Krishna2323.

    Please re-state the problem that we are trying to solve in this issue.

    When an admin searches the expense Category picker and nothing matches, the picker shows only No results found. It gives them no way to create the category they just typed.

    What is the root cause of that problem?

    This is a new feature, not a bug. CategoryPicker only sets a No results found header when the search has no matches (CategoryPicker/index.tsx:163). Nothing turns the search text into a new category. Today, the only way to create one is the separate + page.

    What changes do you think we should make in order to solve the problem?

    1. Extend useUpdateTransactionCategory. Add an optional second argument: updateCategory(category, policyCategories?). When it's passed, the existing-expense branch sends it to updateMoneyRequestCategory instead of the hook's policyCategories. Violations then see the new or re-enabled category. The split-draft and new-draft branches don't change. No other hook copies the three-way branch.

    2. Add a small hook, for example useCreateCategoryFromSearch({policy, policyCategories, updateCategory}). It returns createAndApplyCategory(searchText), which:

      • sets name = StringUtils.sanitizeName(searchText)
      • re-enables the category with setWorkspaceCategoryEnabled if a disabled one has the same decoded name. Otherwise it calls createPolicyCategory with the same onboarding and review-task data the create page passes.
      • calls updateCategory(name, policyCategoriesWithCategory), where that map has the category marked enabled

      The hook doesn't navigate.

    3. Add an opt-in onCreateCategory?: (name: string) => void prop to CategoryPicker. Use StringUtils.sanitizeName(debouncedSearchValue) everywhere:

      • Row text: a new Create “<name>” category translation, added to en.ts only. The other language files are generated by generateTranslations.yml.
      • Validity check: show the row only when the prop is set, the name isn't empty, there are zero matches, and either getCategoryNameError(policyCategories, name) returns nothing or a disabled category has the same name.
      • Created name: the row's selection calls onCreateCategory(name) instead of onSubmit.

      The row is a one-item section, so No results found still shows above it.

    4. Wire it up where the + shows today (canCreateCategoryInSitu):

      • Full-page picker (DynamicIOURequestStepCategory.tsx:162-179): move the navigation at the end of updateCategory into a shared helper. Both the normal pick and the create row call it. That keeps the CATEGORIZE branch that goes forward to Confirmation, and otherwise calls Navigation.goBack(backPath, {shouldSkipFocusRestore: true}). It uses backPath, not basePath.
      • Confirmation dropdown (CategoryFieldDropdown.tsx:51-82): pass onCreateCategory through CategoryPickerModal only when canAddCategory is true. The modal closes after the tap, just as it does after a normal pick.

      Every other CategoryPicker use stays unchanged. The + create page also stays unchanged.

    5. Tests

      • The tap itself. Start with a disabled Training category, search Training, and tap the row. Check that Training is enabled again, no new category is created (no CreateWorkspaceCategories write), and the expense's category is Training. Add a second test where no category exists: one is created, enabled, and set on the expense.
      • useUpdateTransactionCategory: an override passed to updateCategory reaches updateMoneyRequestCategory. Without one, the hook's policyCategories is used.
      • Row visibility: valid name, name with leading or trailing spaces, reserved names (Uncategorized, ###), HTML, more than 255 characters, a partial match, and a picker without onCreateCategory.
    Code references

    What alternative solutions did you explore? (Optional)

    • Open the existing create page pre-filled with the name. This is simpler, but it adds the confirmation step the issue rules out.
    • Show a button in listEmptyContent. It renders outside the list, so you can't reach it with the keyboard.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105298) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  6. Krishna2323 commented on Nov 1, 2026

    @Krishna2323
    Contributor

    @MelvinBot implement this

  7. 24 remaining items

  8. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  9. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  10. mallenexpensify commented on Nov 13, 2026

    @mallenexpensify
    Contributor

    Claude posting on behalf of Matt:

    Your call. Job price: $175 (standard, no Help Wanted, assigned 2026-10-28).

    Deploy blocker #105809 came from #105575. Krishna2323 confirms it and asks for no penalty: comment. The ask is not in the increase template. Krishna2323 asked JS00001 to rule: comment. No ruling yet.

    Next: confirm 50%, press Caps+Y, then pay.

    Evidence

    PAYPREP v1

  11. Krishna2323 commented on Nov 13, 2026

    @Krishna2323
    Contributor

    @JS00001 please check this comment when you get a chance. Thanks!

  12. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    @JS00001 👀 above plz

    The affected flow was already broken in production.

    Makes me think we might not want to account for the regression. Thx

  13. JS00001 commented on Nov 16, 2026

    @JS00001
    Contributor

    Yep, that sounds good to me, we can remove the regression

  14. JmillsExpensify commented on Nov 16, 2026

    @JmillsExpensify
    ContributorAuthor

    Agree.

  15. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Krishna2323 due $175 via NewDot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ImprovementItem broken or needs improvement.InternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions