Skip to content

Fix 'Not here' page when creating workspace for client with makeMeAdmin off#86331

Open
allgandalf wants to merge 12 commits intoExpensify:mainfrom
allgandalf:fix-not-here-page-workspace-creation-for-client
Open

Fix 'Not here' page when creating workspace for client with makeMeAdmin off#86331
allgandalf wants to merge 12 commits intoExpensify:mainfrom
allgandalf:fix-not-here-page-workspace-creation-for-client

Conversation

@allgandalf
Copy link
Copy Markdown
Contributor

@allgandalf allgandalf commented Mar 25, 2026

Explanation of Change

When an approved accountant creates a workspace for a client with "Keep me as admin" toggled off, the app navigates to the workspace page where the user sees a "Not here" page because the backend never adds them as a member.

This PR fixes this by:

  1. Showing a success confirmation page instead of navigating to the workspace when makeMeAdmin=false and the owner is a different user. This matches OldDot behavior where the accountant gets a success message and does NOT navigate to the workspace.
  2. Fixing optimistic employeeList in buildPolicyData to not add the caller when makeMeAdmin=false, since the backend never adds them — the optimistic data now matches server behavior.

Fixed Issues

$ #83995

Tests

  1. Set your account as an approved accountant (requires backend access or ngrok)
  2. Go to Workspaces > New workspace
  3. Select another account as Owner
  4. Toggle OFF "Keep me as an admin"
  5. Submit the workspace creation form
  6. Verify a success confirmation page appears with the heading "You've created a workspace for your client!" and a "Got it" button
  7. Tap "Got it"
  8. Verify you are taken back to the Workspaces list (NOT to the workspace page)
  9. Repeat steps 2-5 but with "Keep me as an admin" toggled ON
  10. Verify you are navigated to the workspace page as normal
  • Verify that no errors appear in the JS console

Offline tests

  1. Create a workspace for a client with "Keep me as admin" OFF while online
  2. Verify the success page appears
  3. Toggle airplane mode ON before tapping "Got it"
  4. Tap "Got it" — verify you return to the Workspaces list without errors

QA Steps

  1. Log in as an approved accountant (use ngrok or local backend)
  2. Create a new workspace, select a different owner, toggle OFF "Keep me as an admin"
  3. Verify a confirmation page appears saying "You've created a workspace for your client!"
  4. Tap "Got it" and verify you return to the Workspaces list
  5. Verify the workspace was created and the accountant is NOT a member of it
  6. Repeat with "Keep me as an admin" ON — verify normal workspace navigation
  • 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
    • 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

Screen.Recording.2026-03-26.at.10.57.24.AM.mov

Backend never adds the caller when they opt out of admin, so the
optimistic data should match.
When creating a workspace for a client without keeping admin role,
navigate to a confirmation page instead of the workspace page that
the user won't have access to.
@allgandalf allgandalf requested review from a team as code owners March 25, 2026 16:12
@melvin-bot melvin-bot bot requested a review from QichenZhu March 25, 2026 16:12
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 25, 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

@melvin-bot melvin-bot bot requested review from JmillsExpensify and removed request for a team March 25, 2026 16:12
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 25, 2026

@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 removed the request for review from a team March 25, 2026 16:12
@allgandalf
Copy link
Copy Markdown
Contributor Author

@JmillsExpensify please hold on review, the C+ still needs to test the issue with my local dev setu

@allgandalf
Copy link
Copy Markdown
Contributor Author

allgandalf commented Mar 25, 2026

@QichenZhu , For you to connect and test this correctly, lets test this in my VM, i am available between:

  • 01:30–06:30 UTC
  • 08:30–11:30 UTC
  • 13:30–15:30 UTC

Does any of the above time work with you ? if not i can probably keep my VM active and then you can test according to your time. let me know

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 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/ROUTES.ts 15.70% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
src/libs/actions/Policy/Policy.ts 65.11% <100.00%> (-0.21%) ⬇️
...gation/AppNavigator/ModalStackNavigators/index.tsx 6.92% <0.00%> (-0.01%) ⬇️
src/pages/workspace/WorkspaceConfirmationPage.tsx 0.00% <0.00%> (ø)
...ges/workspace/WorkspaceConfirmationSuccessPage.tsx 0.00% <0.00%> (ø)
... and 11 files with indirect coverage changes

@QichenZhu
Copy link
Copy Markdown
Contributor

Does any of the above time work with you ?

@allgandalf 01:30–06:30 UTC and 08:30–11:30 UTC work for me.

@allgandalf
Copy link
Copy Markdown
Contributor Author

…mber

When makeMeAdmin=false and the owner is different, the backend never
adds the caller to the workspace. The optimistic policy data should
not set role=ADMIN, otherwise the workspace briefly appears in the
accountant's list before being removed on server response.
Comment on lines +4063 to +4065
createdForClient: {
title: '¡Has creado un espacio de trabajo para tu cliente!',
description: 'Excelentes noticias 🎉. Contáctanos si necesitan ayuda con la configuración.',
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.

@QichenZhu
Copy link
Copy Markdown
Contributor

An edge case: do we need a fail page when creating a workspace for a non-existent user?

Screen.Recording.2026-03-26.at.8.12.39.PM.mov

@QichenZhu
Copy link
Copy Markdown
Contributor

QichenZhu commented Mar 26, 2026

NAB: #admins room shows in LHN even when the current user is not the admin or owner. This also happens on main.

Screen.Recording.2026-03-26.at.8.38.00.PM.mov

@allgandalf
Copy link
Copy Markdown
Contributor Author

good point! i think we should handle that — the backend returns a 404 when the owner email doesnt have a proper account. i'll add an error state for that. or alternatively, we could just show the generic error on the workspace page (which already happens via onyxData in the 404 response). wdyt?

@QichenZhu
Copy link
Copy Markdown
Contributor

@trjExpensify
Copy link
Copy Markdown
Contributor

Mhm.. did you test this on Expensify Classic? I'm not aware of the restriction on existing accounts only.

Copy link
Copy Markdown
Contributor

@JmillsExpensify JmillsExpensify left a comment

Choose a reason for hiding this comment

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

LGTM

@trjExpensify
Copy link
Copy Markdown
Contributor

Mhm.. did you test this on Expensify Classic? I'm not aware of the restriction on existing accounts only.

@QichenZhu @allgandalf were you able to test this on Classic?

@QichenZhu
Copy link
Copy Markdown
Contributor

I'm not able to test it. I don't have an approved accountant account, and I don't know how to test OldDot using the ngrok server.

@allgandalf
Copy link
Copy Markdown
Contributor Author

Mhm.. did you test this on Expensify Classic? I'm not aware of the restriction on existing accounts only.

@QichenZhu @allgandalf were you able to test this on Classic?

Just started my day, will check

@allgandalf
Copy link
Copy Markdown
Contributor Author

I'm not able to test it. I don't have an approved accountant account, and I don't know how to test OldDot using the ngrok server.

Okay i tested on OD and it doesn't block, @QichenZhu i also tested on my branch locally and it works, i think there must be some issue when you tested, you can continue with checklist i think and test again , please DM me on slack when you want to test again, thanks !

@QichenZhu
Copy link
Copy Markdown
Contributor

@allgandalf CreateWorkspace still returned an error, and the workspace was not created. Am I missing something?

Screen.Recording.2026-03-31.at.8.23.32.PM.mov

@QichenZhu
Copy link
Copy Markdown
Contributor

Also, what do you think about #86331 (comment)? I think it doesn't block this PR, but blocks the original issue.

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