Skip to content

[NewFeature] Rework: Add ability to require attendees based on category selection#78315

Merged
JS00001 merged 15 commits intoExpensify:mainfrom
ikevin127:ikevin127-categoryRequireAttendeesReopen
Jan 7, 2026
Merged

[NewFeature] Rework: Add ability to require attendees based on category selection#78315
JS00001 merged 15 commits intoExpensify:mainfrom
ikevin127:ikevin127-categoryRequireAttendeesReopen

Conversation

@ikevin127
Copy link
Contributor

@ikevin127 ikevin127 commented Dec 23, 2025

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.
  • Must have Settings > Troubleshoot > Use Staging Server enabled (this because BE not deployed to production yet).

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 initial PR ❌ 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.
  • 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 Dec 23, 2025

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

@ikevin127 ikevin127 force-pushed the ikevin127-categoryRequireAttendeesReopen branch from bedf24c to 106c7da Compare December 23, 2025 02:20
@github-actions
Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@ikevin127 ikevin127 force-pushed the ikevin127-categoryRequireAttendeesReopen branch from 106c7da to 1bc3f55 Compare December 23, 2025 02:21
@ikevin127 ikevin127 force-pushed the ikevin127-categoryRequireAttendeesReopen branch from 1bc3f55 to 23d97e3 Compare December 23, 2025 02:24
@codecov
Copy link

codecov bot commented Dec 23, 2025

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.47% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
.../components/MoneyRequestConfirmationListFooter.tsx 84.32% <100.00%> (+0.11%) ⬆️
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/ROUTES.ts 12.52% <0.00%> (-0.12%) ⬇️
src/hooks/useViolations.ts 3.17% <50.00%> (-0.06%) ⬇️
...gation/AppNavigator/ModalStackNavigators/index.tsx 8.22% <0.00%> (-0.02%) ⬇️
src/libs/TransactionUtils/index.ts 72.17% <75.00%> (-0.12%) ⬇️
... and 11 more
... and 7 files with indirect coverage changes

@ikevin127 ikevin127 marked this pull request as ready for review December 23, 2025 04:48
@ikevin127 ikevin127 requested review from a team as code owners December 23, 2025 04:48
@melvin-bot melvin-bot bot requested a review from jayeshmangwani December 23, 2025 04:48
@melvin-bot
Copy link

melvin-bot bot commented Dec 23, 2025

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

@jayeshmangwani
Copy link
Contributor

@ikevin127 Based on this code, Attendee Tracking defaults to true on Control policies when isAttendeeTrackingEnabled attribute is missing, so we may need to reuse that logic on our PR.

// For backwards compatibility with Expensify Classic, we assume that Attendee Tracking is enabled by default on
// Control policies if the policy does not contain the attribute
const isAttendeeTrackingEnabled = policy?.isAttendeeTrackingEnabled ?? true;

@ikevin127
Copy link
Contributor Author

@jayeshmangwani Makes sense - updated ✅

@ikevin127
Copy link
Contributor Author

⚠️ There was another issue that I didn't check / fix yet - will get on it soon - added [WIP] until confirmed as fixed ✅

@ikevin127 ikevin127 changed the title [NewFeature] Rework: Add ability to require attendees based on category selection [WIP][NewFeature] Rework: Add ability to require attendees based on category selection Dec 24, 2025
@ikevin127 ikevin127 changed the title [WIP][NewFeature] Rework: Add ability to require attendees based on category selection [NewFeature] Rework: Add ability to require attendees based on category selection Dec 25, 2025
@ikevin127
Copy link
Contributor Author

⚠️ There was another issue that I didn't check / fix yet - will get on it soon - added [WIP] until confirmed as fixed ✅

@jayeshmangwani ✅ This was addressed by using data we have on FE side before actually opening the report (BE would return the data if this is done first), then rendering the error in Reports > Expenses based on that. I added the issue / test in PR description for verification purposes.

☝️ Noting that a FE fix was suggested here by an engineer, even though my take was that this could probably be handled on BE side when Reports > Expenses page is opened and search API endpoint is called.

🟢 Ready for review!

@ikevin127
Copy link
Contributor Author

✅ Merged main to resolve conflict. @JS00001 Before merging please refer to this comment to make sure we're aligned for a specific case when it comes to FE to BE expectations - thank you!

@JS00001
Copy link
Contributor

JS00001 commented Dec 31, 2025

These two should be handled by BE, as the FE fallback doesn't mean that we're toggling the switch ON - it's just a visual switch-ON fallback that IMO doesn't make any sense - not sure why this was added in the first place.

@ikevin127 Is this saying that the BE should create policies with the value for attendee tracking required as true/enabled by default?

@ikevin127
Copy link
Contributor Author

Not quite - according to this code comment referenced here there are cases in which, as the comment says:

with Expensify Classic, we assume that Attendee Tracking is enabled by default on
// Control policies if the policy does not contain the attribute

but this does not make sense to do on the FE side because:

  • scenario 1: having the toggle fallback to true does not actually make the variable true in BE (that's why we changed this to false) - it just causes issues on FE side because it looks true but it actually isn't
  • scenario 2: we don't have / know of any variable that FE could use to actually set the toggle true via API and we also don't fully understand the specifics in which - when creating a new WS in ND or logging into an existing OD account on ND - we should have attendee tracking enabled by default (this can't be assumed without a clear design doc)

I would assume that if a WS was created in OD (scenario 2), then user logged in on ND, the variable would already be toggled ON if it was previously toggled ON in OD.

👉 This is what I mean by 'this should be handled on BE side' - FE shouldn't be tasked with keeping track of this variable across OD / ND in case variables differ - they should be unified and already be ON if it was turned ON before.

@JS00001
Copy link
Contributor

JS00001 commented Jan 5, 2026

@ikevin127 And this issue is currently still causing the bugs from above?

@ikevin127
Copy link
Contributor Author

ikevin127 commented Jan 5, 2026

@JS00001 No - everything works well now since we removed that FE-only fallback to true, the only concern was that BE should handle the OD case if that's actually something we want.

🟢 This is ready for merge!

@JS00001
Copy link
Contributor

JS00001 commented Jan 6, 2026

I dont think we should add true as the value via only old dot, if this doesnt cause any regressions, I'm fine with keeping this current implementation

@ikevin127
Copy link
Contributor Author

ikevin127 commented Jan 6, 2026

@JS00001 Changes applied - should be ready to merge! 🟢

Commit 👇 below was pushed for a typecheck issue - still ready to merge 🙌

@JS00001 JS00001 merged commit 6020367 into Expensify:main Jan 7, 2026
31 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jan 7, 2026

✋ 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
Copy link
Contributor

OSBotify commented Jan 7, 2026

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

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

@jponikarchuk
Copy link

This PR failing because of an issue
This issue is reproducible in: All platforms

mountiny added a commit that referenced this pull request Jan 7, 2026
OSBotify pushed a commit that referenced this pull request Jan 7, 2026
[NO QA] Revert #78315

(cherry picked from commit e94e280)

(cherry-picked to staging by mountiny)
@OSBotify
Copy link
Contributor

OSBotify commented Jan 8, 2026

🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.95-5 🚀

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

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.

6 participants