Skip to content

feat: add ability to require attendees based on category selection (rework)#79050

Merged
JS00001 merged 20 commits intoExpensify:mainfrom
ikevin127:ikevin127-categoryRequireAttendeesRework
Jan 14, 2026
Merged

feat: add ability to require attendees based on category selection (rework)#79050
JS00001 merged 20 commits intoExpensify:mainfrom
ikevin127:ikevin127-categoryRequireAttendeesRework

Conversation

@ikevin127
Copy link
Contributor

@ikevin127 ikevin127 commented Jan 7, 2026

Explanation of Change

We’re expanding support for required category fields and coding. Specifically, we’ll add more category-based rules within each NewDot category. For example: “If the category is Meals & Entertainment, then require the Attendees field.”

Scope:

  • Make Description hint field more discoverable: Specifically, we'll move Description hint field below Payroll code and above Delete category
  • Add a Require fields push row: This new row contains options for both Require description and Require attendees, like so
  • Require attendees logic: We'll flag an Attendees violation on an expense when either of the following is true:
    • The attendees array is empty, or
    • The length of the attendees array minus the expense creator is zero.
  • Inline violation: If a member doesn't add multiple attendees when required for a given category, we'll show an inline violation using standard patterns, like so Attendees required for this category.

👁️ See issue OP / screenshots for more details / UI representation.

Fixed Issues

$ #76155
PROPOSAL:

Tests

Preconditions:

  • Must be on a Control policy.
  • Must Workspace Settings > More features > Rules enabled.
  • Must have Workspace Settings > Rules > Attendee tracking enabled.

I. Enable Attendees Required for Category

  1. Navigate to Workspace Settings → Categories → [Category] Settings.
  2. Verify that the "Required fields" row is showing.
  3. Click on "Required fields" and verify that:
  • the header copy reads "This will apply to all expenses categorized as {Category}"
  • there are 2 ON / OFF toggles present: Require description / Require attendees
  1. Enable Require attendees.
  2. Create an expense with that [Category], verify violation appears when no attendees (besides yourself) are added.
  3. Add an attendee, verify violation clears.

II. Confirmation Page Validation

  1. Create a new expense from FAB.
  2. Select a category with attendees required.
  3. Attempt to submit without adding attendees.
  4. Verify error message "Attendees required for this category" appears.
  5. Add an attendee and verify submission proceeds.

III. Existing Expense Violation Display

  1. View an existing expense with the category that now requires attendees.
  2. Verify the attendees field shows an error indicator.
  3. Verify editing attendees to add someone clears the violation.

🧪 Tests from first PRs ❌ regressions

I. Expense - App crash after deleting category in the list #78076

  1. Open app and login into existing account.
  2. Create Workspace.
  3. Go to category and open one of the categories.
  4. Delete the category using RHP menu.
  5. Verify that the app does not crash.

II. Expense - "Multiple attendees required for this category" appears when splitting expense offline #78132

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  1. Open app and login into existing account.
  2. Go to workspace settings > Categories.
  3. Open Advertising settings.
  4. Click Require fields.
  5. Enable Require attendees.
  6. Go back to workspace chat.
  7. Create an expense with Advertising category and two attendees.
  8. Open expense report.
  9. Go offline.
  10. Click More > Split > Save.
  11. Verify that "Multiple attendees required for this category" error will not appear since the splits have two attendees.

III. Reports - "Multiple attendees required for this category" does not appear on expense row #78040

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  1. Go to workspace chat.
  2. Create two expenses with Advertising category.
  3. Go to Workspace Settings > Categories.
  4. Open Advertising settings.
  5. Click Require fields.
  6. Enable Require attendees.
  7. Navigate straight to Reports > Expenses without opening the report first.
  8. Verify that "Multiple attendees required for this category" violation is shown on the expense row.

Note

Should work the same for tracked expenses (created in SelfDM). The only exception is Invoices where Workspace-related violations won't apply since invoice is sent to individuals.

🧪 Tests from second PRs ❌ regressions

I. Reports - App crashes after removing expense from report #79003

  1. Go to a workspace chat.
  2. Create an expense.
  3. Go to Reports > Expenses.
  4. Select the expense via checkbox.
  5. Click dropdown button > Move expense.
  6. Click Remove from report.
  7. Verify that app will not crash.

II. Reports - Violation appears twice #79007

  1. Go to a workspace chat.
  2. Create an expense without category and hold the expense.
  3. Go to Reports > Expenses.
  4. Missing category and hold violation will only appear one time (not duplicated).

III. Invoice - Invoice cannot be sent when user selects a category that requires attendees #79008

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  • Make Advertising category require attendees in category settings.
  • Invoice is enabled.
  1. Open FAB > Send invoice.
  2. Enter amount > Next.
  3. Select a user > Next.
  4. On confirm page, select Advertising category.
  5. Proceed to next page and enter company details (if this is the first time invoice is sent) -> Invoice is sent successfully.
  6. Open FAB again > Send invoice.
  7. Enter amount > Next.
  8. Select a user > Next.
  9. On confirm page, select Advertising category.
  10. Click Send invoice.
  11. Verify that invoice is sent successfully.

VI. Expense - No attendee require violation on confirm page when there is no additional attendee #79011

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  • Make Advertising category require attendees in category settings.
  1. Go to self DM.
  2. Click + > Create expense > Manual.
  3. Enter amount > Next.
  4. On confirm page, select Advertising category and click Attendees.
  5. Add one more attendee and click Save.
  6. Click Create expense.
  7. Open the expense.
  8. Click Attendees and remove the attendee added in Step 5.
  9. Go back to self DM.
  10. Click Submit it to someone.
  11. Select the workspace chat.
  12. Enter merchant.
  13. Without selecting additional attendee, click Create expense.
  14. Verify that app will show attendee required violation on confirm page when there is no additional attendee.
  15. Select an additional attendee and click Create expense.
  16. Verify that the expense is submitted successfully.

V. Report - Violation for required attendee, disappears after opening "Attendee" field #79013

Preconditions:

  • Workspace is on "Control" policy.
  • "Rules" and "Attendee tracking" enabled.
  • "Required attendee" for selected category is enabled.
  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Start a manual expense creation flow.
  4. Select a category with "Required Attendee" enabled.
  5. Try to submit expense without adding an extra attendee.
  6. Note that a "Required attendee" violation appears.
  7. Open "Attendee" field and return without adding a new attendee.
  8. Verify that violation for required attendees remains visible when returning from "Attendee" field, if no new attendee was selected.

VI. Reports - Violation does not show up on expense row when additional attendee is not added #79017

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  • Make Advertising category require attendees in category settings.
  1. Go to workspace chat.
  2. Create an expense with any category except Advertising. Do not add additional attendee.
  3. Open expense report.
  4. Change category to Advertising.
  5. Go to Reports > Expenses.
  6. Go to Reports > Reports.
  7. Verify that:
    -> Reports > Expenses: "Multiple attendees required for this category" violation will show up on expense row when additional attendee is not added.
    -> Reports > Reports: "Report contains expenses with violations." violation will show up on report row when additional attendee is not added.
  • Verify that no errors appear in the JS console

Offline tests

I. Offline Toggle

  1. Go to Category Settings → Require fields.
  2. Go offline.
  3. Toggle "Require attendees".
  4. Verify optimistic UI update shows pending state.
  5. Verify going back online syncs the change.

II. Offline Expense Creation

  1. Go offline.
  2. Create expense with category requiring attendees (no attendees added).
  3. Verify local validation blocks submission with error.
  4. Add attendee offline, verify expense can be created.
  5. Go online and verify expense syncs correctly.

III. Offline Category Change

  1. Create an expense with category A (no attendees required).
  2. Go offline.
  3. Edit expense and change to category B (attendees required).
  4. Verify violation appears immediately.
  5. Verify adding attendee clears violation while still offline.

QA Steps

Same as Tests.

  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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
    • 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: HybridApp
android-hybrid.mp4
Android: mWeb Chrome
android-mweb.mp4
iOS: HybridApp
ios-hybrid.mov
iOS: mWeb Safari
ios-mweb.mov
MacOS: Chrome / Safari
web.mov

@melvin-bot
Copy link

melvin-bot bot commented Jan 7, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 83.76% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
.../components/MoneyRequestConfirmationListFooter.tsx 84.07% <100.00%> (+0.11%) ⬆️
src/components/Search/index.tsx 30.35% <100.00%> (+0.15%) ⬆️
src/libs/API/types.ts 100.00% <ø> (ø)
...gation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 75.00% <ø> (ø)
src/libs/ReportUtils.ts 71.70% <100.00%> (+0.01%) ⬆️
src/libs/SearchUIUtils.ts 60.13% <100.00%> (+0.02%) ⬆️
...es/iou/request/step/IOURequestStepConfirmation.tsx 55.41% <ø> (-0.41%) ⬇️
... and 15 more
... and 26 files with indirect coverage changes

@jayeshmangwani
Copy link
Contributor

I’ll review the PR once it’s ready, and apologies for having to revert it twice.

@ikevin127
Copy link
Contributor Author

No worries, quite a complex PR and didn't expect so many regressions either - I'll keep working on them as they appear and hopefully we'll eventually get to a point where there won't be any more regressions.

@ikevin127 ikevin127 marked this pull request as ready for review January 8, 2026 22:22
@ikevin127 ikevin127 requested review from a team as code owners January 8, 2026 22:22
@melvin-bot melvin-bot bot requested review from jayeshmangwani and joekaufmanexpensify and removed request for a team January 8, 2026 22:22
@melvin-bot
Copy link

melvin-bot bot commented Jan 8, 2026

@jayeshmangwani 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]

@JS00001
Copy link
Contributor

JS00001 commented Jan 14, 2026

@ikevin127 more conflicts 😢

JS00001
JS00001 previously approved these changes Jan 14, 2026
@ikevin127
Copy link
Contributor Author

@JS00001 For reference: latest conflict came from this (merged yesterday) PRs commit 86bb98d, which updated code that conflicted with the fix I pushed in commit 452b3bb, meaning this test:

VI. Reports - Violation does not show up on expense row when additional attendee is not added #79017

Preconditions:

  • Rules are enabled.
  • Enable Attendee tracking in Rules.
  • Make Advertising category require attendees in category settings.
  1. Go to workspace chat.
  2. Create an expense with any category except Advertising. Do not add additional attendee.
  3. Open expense report.
  4. Change category to Advertising.
  5. Go to Reports > Expenses.
  6. Go to Reports > Reports.
  7. Verify that:
    -> Reports > Expenses: "Multiple attendees required for this category" violation will show up on expense row when additional attendee is not added.
    -> Reports > Reports: "Report contains expenses with violations." violation will show up on report row when additional attendee is not added.

The issue was that PR Show proper violations when offline removed a big chunk of code filteredViolations which posed problems, here's explanation as to how I handled it to make sure we fix both our test and maintain their PRs fix:

The core issue is that both scenarios need fresh data, but from different sources:

  • Offline violations test: Needs raw violations from Onyx (not filtered snapshot)
  • Attendee tracking test: Needs fresh policy.isAttendeeTrackingEnabled from Onyx (not stale snapshot)

The Solution
The issue is on line 141 of TransactionListItem.tsx:

const policyForViolations = isEmptyObject(snapshotPolicy) ? parentPolicy : snapshotPolicy;

This prefers snapshot policy over live Onyx policy, but it should be reversed to prefer live Onyx policy (like the old filteredViolations did with onyxPolicy ?? snapshotPolicy).

Why This Fixes Both Tests:

Scenario Current (Broken) Fix
Offline violations ✅ Works - Using violations from Onyx directly ✅ Still works - no change to violations source
Attendee tracking ❌ Fails - snapshotPolicy.isAttendeeTrackingEnabled is undefined ✅ Works - parentPolicy (live Onyx) has isAttendeeTrackingEnabled

The Fix
Change line 141 from:

const policyForViolations = isEmptyObject(snapshotPolicy) ? parentPolicy : snapshotPolicy;

To:

// Prefer live Onyx policy data over snapshot to ensure fresh policy settings like isAttendeeTrackingEnabled
const policyForViolations = parentPolicy ?? snapshotPolicy;

This ensures:

  • Offline: Violations come from Onyx (violations prop) - unchanged
  • Attendee tracking: Policy comes from live Onyx (parentPolicy) with existing isAttendeeTrackingEnabled, falling back to snapshot if Onyx is empty

I resolved conflicts carefully and retested our test and their test - both tests are passing ✅
Hopefully we can merge before other conflicts arise! 💀

@JS00001 JS00001 merged commit 878370a into Expensify:main Jan 14, 2026
30 checks passed
@OSBotify
Copy link
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.

@ikevin127
Copy link
Contributor Author

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.3-0 🚀

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

@Gonals
Copy link
Contributor

Gonals commented Jan 16, 2026

This caused a blocker: #79709

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 9.3.3-8 🚀

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

const isMissingAttendeesViolation = getIsMissingAttendeesViolation(policyCategories, iouCategory, iouAttendees, currentUserPersonalDetails, policy?.isAttendeeTrackingEnabled);
if (formError === 'violations.missingAttendees' && !isMissingAttendeesViolation) {
setFormError('');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

reverting the above change fixed the problem with the persistent error #79902

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