Skip to content

[Submit] Submit button with manager email prompt take 2 - #94392

Merged
iwiznia merged 21 commits into
Expensify:mainfrom
hungvu193:revert-94333-revert-87998
Jun 30, 2026
Merged

[Submit] Submit button with manager email prompt take 2#94392
iwiznia merged 21 commits into
Expensify:mainfrom
hungvu193:revert-94333-revert-87998

Conversation

@hungvu193

@hungvu193 hungvu193 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Add a new ReportSubmitTo Popover that will be shown when a member of submit workspace try to submit an expense.

Design doc section

Fixed Issues

$ #87264
$ #94254
$ #94323
$ #94304
$ #94281
PROPOSAL: N/A

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."
Prerequisite: You're a member of a submit workspace.

Test 1: Expense view

  1. Go to submit workspace and submit an expense.
  2. Verify that a Popover appears and you're able to choose a manager to submit your expense to.
  3. Choose a manager and press confirm.
  4. Verify that you can submit your expense.
  5. Create another expense and click on it to see detail
  6. Try to submit expense from Submit header button
  7. Verify they you can choose a manager and submit expense.

Test 2: Search view

  1. Go to submit workspace
  2. Go to search (Spend) and try to submit that expense.
  3. Verify that a Popover appears and you're able to choose a manager to submit your expense to.

** Test 3: More Button**

  1. Submit an expense.
  2. Approve that expense > Paid it.
  3. Verify that More button display correctly, we can press that button to open the popover.
  • 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
Screen.Recording.2026-05-27.at.17.19.12.mov
Android: mWeb Chrome
Screen.Recording.2026-05-27.at.17.22.55.mov
iOS: Native
Screen.Recording.2026-05-27.at.17.09.33.mov
iOS: mWeb Safari
Screen.Recording.2026-05-27.at.17.11.41.mov
MacOS: Chrome / Safari
Screen.Recording.2026-05-26.at.22.30.54.mov

@melvin-bot

melvin-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

@hungvu193

Copy link
Copy Markdown
Contributor Author

@MelvinBot Fix the eslint

@codecov

codecov Bot commented Jun 24, 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 94.02% <ø> (ø)
src/components/ButtonWithDropdownMenu/index.tsx 89.65% <100.00%> (+0.44%) ⬆️
src/components/MoneyReportHeaderMoreContent.tsx 100.00% <100.00%> (ø)
...chList/ListItem/ExpenseReportListItemRow/index.tsx 0.00% <ø> (ø)
...earch/SearchList/ListItem/ReportListItemHeader.tsx 91.66% <100.00%> (+0.75%) ⬆️
.../TransactionListItem/TransactionListItemNarrow.tsx 0.00% <ø> (ø)
...em/TransactionListItem/TransactionListItemWide.tsx 0.00% <ø> (ø)
src/components/TransactionItemRow/index.tsx 83.05% <100.00%> (+0.29%) ⬆️
src/hooks/useSelectionModeReportActions.ts 91.66% <100.00%> (+0.49%) ⬆️
src/libs/PersonalDetailsUtils.ts 81.17% <100.00%> (+0.23%) ⬆️
... and 21 more
... and 11 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 The ESLint check is now passing ✅ (run, 1m23s).

When you posted, the check was still in progress on the latest commit (1371cbf) — it has since completed green, so there's nothing to fix. I also ran the repo's lint script locally against all changed files in this PR and it reported no errors.

If you're seeing an ESLint error locally that CI isn't catching, let me know the exact message and file and I'll take a look.

@hungvu193

Copy link
Copy Markdown
Contributor Author

@MelvinBot Resolve the conflicts

…7998

Co-authored-by: Hans Vu <hungvu193@users.noreply.github.com>

# Conflicts:
#	src/hooks/useSelectionModeReportActions.ts
@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Resolved the merge conflicts with main and pushed the merge to this PR's branch.

Conflict: src/hooks/useSelectionModeReportActions.ts — an import-only conflict.

How I resolved it:

  • Kept isSubmitPolicy (from @libs/PolicyUtils) — it's a change from this PR and is still used in the merged file (L161, L315).
  • Dropped handleUnvalidatedAccount (from @libs/PaymentUtils) — main replaced its only call site inside shouldBlockAction with Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path)), so it's no longer referenced. Keeping the import would have been an unused-import lint error.
Verification
  • ./scripts/lint.sh src/hooks/useSelectionModeReportActions.ts → ✅ pass
  • npm run typecheck-tsgo → ✅ pass
  • npx prettier --check src/hooks/useSelectionModeReportActions.ts → ✅ pass
  • The Mobile-Expensify submodule pointer was advanced to main's commit as part of the merge (expected).

The PR now shows as mergeable. Please re-test per your Test steps since main was merged in, and let me know if anything looks off.

@hungvu193

Copy link
Copy Markdown
Contributor Author

Fixed 3/4 blockers, there's one remaining with the landscape mode. I'll take another look today.

@hungvu193

Copy link
Copy Markdown
Contributor Author

Fixed the last blocker.

Screen.Recording.2026-06-27.at.18.29.29.mov

@hungvu193
hungvu193 marked this pull request as ready for review June 27, 2026 11:31
@hungvu193
hungvu193 requested review from a team as code owners June 27, 2026 11:31
@melvin-bot
melvin-bot Bot requested review from abzokhattab and heyjennahay and removed request for a team June 27, 2026 11:31
@melvin-bot

melvin-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

@abzokhattab 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 June 27, 2026 11:31
@hungvu193

Copy link
Copy Markdown
Contributor Author

@abzokhattab This is ready for your review 🙇

Comment thread src/hooks/useReportSubmitToPopover.tsx Outdated
Comment thread src/pages/ReportSubmitToContent.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: b12fee0c21

ℹ️ 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 thread src/pages/ReportSubmitToContent.tsx Outdated
Comment thread src/libs/PolicyUtils.ts
Comment thread src/components/ReportSubmitToPopoverAnchor.tsx Outdated
@hungvu193

Copy link
Copy Markdown
Contributor Author

@MelvinBot resolve the failing test and review comments

@github-actions

This comment has been minimized.

@iwiznia
iwiznia merged commit 55e5bed into Expensify:main Jun 30, 2026
42 of 43 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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 Jul 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.4.26-0 🚀

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

@lanitochka17

Copy link
Copy Markdown

Deploy Blocker ##95093 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker ##95095 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker ##95096 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker ##95111 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #95139 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #95155 was identified to be related to this PR.

Comment thread src/libs/PolicyUtils.ts
* Returns the email the expense report should submit to per workspace approval config
* (approval rules, employee submitsTo, or default approver for basic/optional workflows).
*/
function getSubmitToEmail(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>): string {

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.

@hungvu193 hi, I was trying to refactor this to remove the getLoginsByAccountIDs usage. I was wondering why getSubmitToEmail has slightly different logic from getSubmitToAccountID?

Since the name is similar, I was expecting getSubmitToEmail would just call getSubmitToAccountID and get the email from it.

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.

@hungvu193 hi, can you check this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I remember AI complained about a case where submitToAccountID could be invalid, so we have to add an extra check:

    if (!isValidAccountRoute(submitToAccountID)) {
        return defaultApprover;
    }

    return getLoginsByAccountIDs([submitToAccountID]).at(0)?.trim() ?? defaultApprover;

@bernhardoj bernhardoj Jul 5, 2026

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.

@hungvu193 I don't think we need to check whether it's valid or not, if it's not valid, getLoginsByAccountIDs([submitToAccountID]).at(0)?.trim() will be undefined, and the fallback, which is the defaultApprover, will be returned.

return getLoginsByAccountIDs([submitToAccountID]).at(0)?.trim() ?? defaultApprover;

I'm actually more curious about the first 3 lines

App/src/libs/PolicyUtils.ts

Lines 1792 to 1796 in fec6b33

function getSubmitToEmail(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>): string {
const defaultApprover = getDefaultApprover(policy).trim();
if (!expenseReport) {
return defaultApprover;
}

If we look at the getSubmitToAccountID, there is no early return when the expenseReport is undefined.

App/src/libs/PolicyUtils.ts

Lines 1751 to 1761 in fec6b33

function getSubmitToAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, ownerLogin: string | undefined): number {
const approvalRules = policy?.rules?.approvalRules;
if (!isSubmitAndClose(policy) && approvalRules?.length) {
const ruleApprover = getFirstRuleApprover(approvalRules, expenseReport, ownerLogin);
if (ruleApprover) {
return getAccountIDsByLogins([ruleApprover]).at(0) ?? -1;
}
}
return getManagerAccountID(policy, ownerLogin);

When expenseReport is undefined, getFirstRuleApprover will return an empty string because allReportTransactions is empty.

App/src/libs/PolicyUtils.ts

Lines 1692 to 1696 in fec6b33

const allReportTransactions = getAllSortedTransactions(expenseReport?.reportID);
if (!allReportTransactions.length) {
return '';
}

So, it'll go through the getManagerAccountID/getManagerAccountEmail logic.

App/src/libs/PolicyUtils.ts

Lines 1727 to 1746 in fec6b33

function getManagerAccountEmail(policy: OnyxEntry<Policy>, ownerLogin: string | undefined): string {
const defaultApprover = getDefaultApprover(policy);
// For policy using the optional or basic workflow, the manager is the policy default approver.
if (([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy))) {
return defaultApprover;
}
const employee = policy?.employeeList?.[ownerLogin ?? ''];
if (!employee && !defaultApprover) {
return '';
}
return employee?.submitsTo ?? defaultApprover ?? '';
}
function getManagerAccountID(policy: OnyxEntry<Policy>, ownerLogin: string | undefined) {
const managerEmail = getManagerAccountEmail(policy, ownerLogin);
return managerEmail ? (getAccountIDsByLogins([managerEmail]).at(0) ?? -1) : -1;
}

So, getSubmitToEmail and getSubmitToAccountID could behave differently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, getSubmitToEmail and getSubmitToAccountID could behave differently.
Yeah, they serves different purposes.

getSubmitToAccountIDreturns the accountID to whom the given expenseReport submits reports to in the given Policy. While getSubmitToEmail returns the email of the default approver of the workspace, I think I actually need to rename getSubmitToEmail more cleaner since it is inside scope of Submit Workspace project.
With submit workspace, when you tried to submit the expense, a popup will be shown to select the user you want to submit your expense report to, default to the default approver of that workspace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that makes sense 😄

@bernhardoj bernhardoj Jul 6, 2026

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.

@hungvu193 Cool. Btw, how can I test this PR? What is submit workspace. Just want to make sure I don't break anything.

(I don't see the popover on a normal workspace)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Turn on the betas (Edit Permission.ts).
  2. Create a brand new account.
  3. On onboarding steps > Choose "Submit Expense to my employeer" > Complete onboarding.
  4. Submit an expense to your workspace you've created in onboarding.
  5. Notice when submitting expense a popup will be opened for you to select mananger email.

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.

That works, thanks!

Btw, just want to report, I think the vertical padding is too big

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think you're right 😄 Will fix it in another PR

@OSBotify

OSBotify commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.27-2 🚀

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

Bundle Size Analysis (Sentry):

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.

10 participants