Skip to content

fix: use TRACK instead of SUBMIT for Teachers Unite expenses - #97858

Open
huult wants to merge 11 commits into
Expensify:mainfrom
huult:97646-teachers-unite-not-here-rhp-add-expense
Open

fix: use TRACK instead of SUBMIT for Teachers Unite expenses#97858
huult wants to merge 11 commits into
Expensify:mainfrom
huult:97646-teachers-unite-not-here-rhp-add-expense

Conversation

@huult

@huult huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Teachers Unite reports don’t support SUBMIT, but the “Add expense” entry points were still hardcoded to use SUBMIT, causing NotFoundPage to show instead of the expense form. The fix hides “Create expense” and “Track distance” for these reports, leaving only “Add existing expense.”

Fixed Issues

$ #97646
PROPOSAL:

Tests

Same QA step

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Precondition

Create two Expensifail accounts:

  • Principal account: A new account or one that is not a member of the "Teachers Unite! testing policy".
  • Teacher account: A separate new Expensifail account.

Principal – "I know a teacher" flow

  1. Log in with the Principal account.
  2. Go to Profile Settings.
  3. Click Save the World.
  4. Click I know a teacher.
  5. Enter the teacher's first and last name.
  6. Enter the Teacher account's email address.
  7. Complete the flow.

Teacher – "I am a teacher" flow

  1. Log in with the Teacher account.
  2. Go to Profile Settings.
  3. Click Save the World.
  4. Click I am a teacher.
  5. Complete the form. In the Principal field, enter the email address of the Principal account from the previous flow.
  6. Tap the FAB and select Create report.
  7. Click Add expense
  8. Verify the dropdown only shows "Add existing expense" — "Create expense" and "Track distance" are hidden.
  • 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
      • 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
Screen.Recording.2026-08-13.at.09.45.42.mov
Android: mWeb Chrome
Screen.Recording.2026-08-13.at.09.43.46.mov
iOS: Native
Screen.Recording.2026-08-13.at.09.51.23.mov
iOS: mWeb Safari
Screen.Recording.2026-08-13.at.09.48.31.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-13.at.09.39.38.mov

@huult
huult requested review from a team as code owners August 5, 2026 08:34
@melvin-bot
melvin-bot Bot requested review from QichenZhu and heyjennahay and removed request for a team August 5, 2026 08:34
@melvin-bot

melvin-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

@QichenZhu 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 requested review from a team, ChavdaSachin and rlinoz and removed request for a team August 5, 2026 08:34
@melvin-bot

melvin-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

@ChavdaSachin @rlinoz One of you needs to 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 August 5, 2026 08:34
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

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 94.85% <ø> (ø)
...neyRequestReportPreview/AddExpenseActionButton.tsx 100.00% <100.00%> (ø)
src/hooks/useDefaultExpensePolicy.tsx 95.83% <100.00%> (ø)
src/hooks/useExpenseActions.ts 66.03% <100.00%> (ø)
src/hooks/usePolicyForMovingExpenses.ts 96.42% <100.00%> (+0.27%) ⬆️
src/libs/PolicyUtils.ts 77.67% <100.00%> (+0.07%) ⬆️
src/libs/isTeachersUnitePolicyID.ts 100.00% <100.00%> (ø)
...c/pages/DynamicNewReportWorkspaceSelectionPage.tsx 86.27% <100.00%> (ø)
...ortActionCompose/AttachmentPickerWithMenuItems.tsx 84.76% <100.00%> (-0.29%) ⬇️
...stReportView/MoneyRequestReportTransactionList.tsx 0.29% <0.00%> (ø)
... and 5 more
... and 9 files with indirect coverage changes

Comment thread src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx Outdated

@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: c6fe293d85

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/libs/ReportUtils.ts Outdated
@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The fix is correct and minimal. Deriving the IOU type from the target report's own policy is the right approach, and it lines up with what getMoneyRequestOptions already permits — for a Teachers Unite expense report, SUBMIT is excluded and TRACK is the only allowed type, so switching the entry points to TRACK means canCreateRequest now passes and the RHP renders instead of NotFoundPage. Both changed entry points read the policy from the correct report. 👍

A few non-blocking things worth a look:

1. A third "Add expense" entry point still hardcodes SUBMIT. useExpenseActions.ts:636 — the top-level ADD_EXPENSE secondary action's own onSelected — still calls startMoneyRequest(CONST.IOU.TYPE.SUBMIT, moneyRequestReport?.reportID, …) on the same report whose subMenuItems you just fixed. It looks unreachable in practice (PopoverMenu opens subMenuItems instead of firing onSelected when submenu items are present, and addExpenseDropdownOptions is always populated), so it's likely dead/defensive code rather than a live bug. Still, for consistency and to avoid a latent regression if the render path ever changes, consider switching it to getMoneyRequestIOUType(moneyRequestReport?.policyID) too.

2. No unit test in the diff. The author checklist has "I added unit tests" checked, but only the two source files changed. A tiny test for getMoneyRequestIOUType (returns TRACK for a Teachers Unite policyID, SUBMIT otherwise) would cheaply guard this regression.

3. PR description nit. The description says isTeachersUnitePolicyID and isTeachersUniteReport were "exported", but only getMoneyRequestIOUType is added to the exports. Harmless (they're only used internally), just worth correcting so the description matches the diff.

Runtime verification

I attempted to verify the fix end-to-end on web (create a Teachers Unite report → Add expense → Create expense / Track distance → confirm the RHP opens instead of the Not Found page). The test was blocked before reaching the report: the "I am a teacher" flow gates on validating a school-domain email as the default contact method via a magic code, which the test account can't receive. This is an environment/account-provisioning limitation, unrelated to the PR — the fix itself could not be exercised in the browser. The code path was verified by inspection instead.

Overall this looks good to merge once the above are considered — none are blockers.

@rlinoz
rlinoz removed the request for review from ChavdaSachin August 5, 2026 11:14
@rlinoz

rlinoz commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@QichenZhu can you review this one please?

@QichenZhu

Copy link
Copy Markdown
Contributor

@rlinoz sure thing!

@QichenZhu

Copy link
Copy Markdown
Contributor

@huult, what's the agreed solution? This PR doesn't seem to align with your comment in the main thread.

@rlinoz Sure! From what I understand, we need to hide the “Create Expense” and “Create Distance” options, as shown in the screenshot. I’ll work on a fix.

@huult

huult commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@huult, what's the agreed solution? This PR doesn't seem to align with your comment in the main thread.

@rlinoz Sure! From what I understand, we need to hide the “Create Expense” and “Create Distance” options, as shown in the screenshot. I’ll work on a fix.

@QichenZhu Initially, after a quick investigation, I thought hiding it was a reasonable solution. However, after implementing the PR, I found a better approach that matches the expected behavior described in the ticket, so I updated the implementation accordingly.

@QichenZhu

Copy link
Copy Markdown
Contributor

Reports created through the Teachers Unite flow ("I know a teacher" / "I am a teacher") live under a shared special policy (CONST.TEACHERS_UNITE.PROD_POLICY_ID/TEST_POLICY_ID). ReportUtils.getMoneyRequestOptions intentionally excludes CONST.IOU.TYPE.SUBMIT for these reports — only TRACK is allowed, since Teachers Unite doesn't support reimbursement.

@huult, is the restriction on the frontend or the backend? Is it intentional or a bug?

cc @rlinoz @heyjennahay

@huult

huult commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

...(!isTeachersUniteReport ? createReportOption : []),

I think this is intentional. I noticed that we already hide the Create Report option for isTeachersUniteReport.

@QichenZhu

Copy link
Copy Markdown
Contributor

Reports created through the Teachers Unite flow ("I know a teacher" / "I am a teacher") live under a shared special policy (CONST.TEACHERS_UNITE.PROD_POLICY_ID/TEST_POLICY_ID). ReportUtils.getMoneyRequestOptions intentionally excludes CONST.IOU.TYPE.SUBMIT for these reports — only TRACK is allowed, since Teachers Unite doesn't support reimbursement.

@huult, is the restriction on the frontend or the backend? Is it intentional or a bug?

cc @rlinoz @heyjennahay

I think this is intentional. I noticed that we already hide the Create Report option for isTeachersUniteReport.

If the restriction is intentional, then your initial approach of hiding the options is probably the right solution.

@rlinoz @heyjennahay, could you clarify the expected behavior?

@rlinoz

rlinoz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Yeah, coming from this internal issue https://github.com/Expensify/Expensify/issues/500617 and this other one #64271, I think we should hide create expense/create report.

cc: @heyjennahay

@huult

huult commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

I’ll update it after I get confirmation from @heyjennahay.

@huult

huult commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@heyjennahay what do you think?

@huult

huult commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@QichenZhu @rlinoz I’ve updated the dropdown so it only shows “Add existing expense”; “Create expense” and “Track distance” are now hidden.

@QichenZhu

Copy link
Copy Markdown
Contributor

Yeah, coming from this internal issue https://github.com/Expensify/Expensify/issues/500617 and this other one #64271, I think we should hide create expense/create report.

Bug: "Create report" is hidden from the + button next to the composer, but it's still available from the FAB. "Create expense" is available from both.

Screen.Recording.2026-08-13.at.7.20.43.PM.mov

@huult cc @rlinoz @heyjennahay

@huult

huult commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Yeah, coming from this internal issue https://github.com/Expensify/Expensify/issues/500617 and this other one #64271, I think we should hide create expense/create report.

Bug: "Create report" is hidden from the + button next to the composer, but it's still available from the FAB. "Create expense" is available from both.

Screen.Recording.2026-08-13.at.7.20.43.PM.mov
@huult cc @rlinoz @heyjennahay

@QichenZhu Yeah, I noticed this while testing the PR as well. However, everything works as expected, and the backend also allows it, so I don’t think this is a bug.

@QichenZhu

Copy link
Copy Markdown
Contributor

However, everything works as expected, and the backend also allows it, so I don’t think this is a bug.

Based on this comment, I don't think it works as expected. The implementation should match the product requirement.

@huult

huult commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@rlinoz what do you think?

@rlinoz

rlinoz commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

asked internally exactly how this should work https://expensify.slack.com/archives/C03U7DCU4/p1786994105546789

@rlinoz

rlinoz commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Ok what I think we need

  1. If the chat is the TU workspace chat a member can only create an expense via split expense
  2. The global create menu should still have all the options, but they should not be able to create a report or expense in the TU workspace, so TU should be hidden in the workspace picker.

@QichenZhu

Copy link
Copy Markdown
Contributor

Sounds good, thanks!

@huult

huult commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-08-18.at.11.50.16.mov

@QichenZhu @rlinoz I’ve updated it. Could you review it?

@huult

This comment was marked as resolved.

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.

4 participants