[$175] Workspace Settings - Error when clicking "ask for admin access" of an existing domain
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.5.39-2 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/tc/TC-917041 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: All Platforms App Component: Workspace Settings
Action Performed:
Preconditions:
- User is logged into an account using a public domain email (e.g., standard personal/testing email).
- A managed domain is already configured and verified on the platform (e.g., expplause.com or applause.expensifail.com).
- Log into the NewDot application with a public domain account.
- Navigate to Workspace > Domains.
- Click + New (or Add Domain).
- Enter an existing registered domain name (such as expplause.com or applause.expensifail.com) and click Continue.
- On the "Domain already set up. Request access" screen, verify that the "Ask for admin access" option is displayed alongside "Never mind".
- Click "Ask for admin access".
- Observe the application response.
Expected Result:
The admin access request should be submitted successfully without errors, and the user should be taken back to the Domains list.
Actual Result:
An error banner stating "We couldn't send your request. Please try again" is displayed, preventing the user from completing the domain access request.
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/682c009e-b48f-47bd-a233-1be7a910439e
Applause Internal Information Exported by: Alberto Gutierrez Bug ID: 7313522
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022121374099981106125
- Upwork Job ID: 2121374099981106125
- Last Price Increase: 2026-11-13
Issue Owner
Current Issue Owner: @amyevans
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/a05a7ec8b11170f1c37fc35b22bef62c46f7dd612d62ce6f60dc40790aac8714
https://platform.applause.com/services/links/v1/external/6ec2d05ad77960672aeca6f6bd49d34e0f82f6914bef1270e5399ece8562eecb
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)
Job added to Upwork: https://www.upwork.com/jobs/~022121374099981106125
🤖 Web test steps verification results: ❌ fail
Blocked on dev NewDot web: the public-email account requires emailed-code validation before proceeding with the domain. The reported failure could not be reproduced or ruled out.
| Step | Status |
|---|---|
Open Workspaces > Domains > New and enter expplause.comNavigated successfully and confirmed the entered domain. |
✅ |
Verify existing-domain actions and request admin accessContinue opened “Validate your account,” requiring an emailed six-digit code unavailable in this run. The existing-domain screen and RequestDomainAdminship response were not reached.Preliminary analysis — low confidence: The underlying failure remains unconfirmed. The client sends the target domainAccountID and displays the reported message through generic failure handling (Domain.ts:565–590). This does not establish a malformed request or a public-email restriction. Alternative considered: The UI offers access requests without checking the requester’s email domain (DomainAlreadyExistsPage.tsx:101–112). Whether the server permits this particular requester remains unknown; existing tests mock the API rather than establish eligibility (DomainAlreadyExistsPageTest.tsx:93–126). Required next evidence: Reproduce with a validated account and capture the failing request’s jsonCode, message and request ID; compare with a same-domain requester. Production-log confirmation was unavailable because this run had no VictoriaLogs access. No code fix is justified yet. ![]() |
❌ |
Proposal
What is the root cause of that problem?
In src/pages/domain/DomainAlreadyExistsPage.tsx:106-112, clicking "Ask for admin access" executes:
requestDomainAdminship(domainAccountID, currentUserAccountID, !!isTransientDomainEntry);
Inside src/libs/actions/Domain.ts:531-591, requestDomainAdminship dispatches the WRITE_COMMANDS.REQUEST_DOMAIN_ADMINSHIP (RequestDomainAdminship) API call with {domainAccountID}.
When the backend rejects the request (which occurs when an account on a public email domain such as @gmail.com or @applause.com requests admin access to an existing private domain without verified association), the API command enters the failureData rollback pipeline.
In Domain.ts:584, failureData maps the failure directly to:
{
onyxMethod: Onyx.METHOD.MERGE,
key: domainErrorsKey,
value: {requestAdminshipError: getMicroSecondOnyxErrorWithTranslationKey('domain.requestAccessError')},
}
In DomainAlreadyExistsPage.tsx:43:
const [requestError] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`, {selector: (errors) => errors?.requestAdminshipError});
This error is passed into <ConfirmationPage.Content requestErrors={requestError}>, causing ConfirmationPageContent to render FormHelpMessage displaying the generic fallback string domain.requestAccessError ("We couldn't send your request. Please try again."). Furthermore, because requestError is truthy, the navigation effect in DomainAlreadyExistsPage.tsx:62-67 does not call goToDomainsList(), leaving the error banner visible on the screen.
In addition, route param parsing on web routes (workspaces/domain-already-exists/:domainAccountID) in src/libs/Navigation/linkingConfig/config.ts:2354-2357 does not include parse: {domainAccountID: Number}, meaning domainAccountID can be passed as a string depending on navigation entry.
What changes do you think we should make in order to solve the problem?
-
Sanitize
domainAccountIDand ensure backend command alignment: Insrc/pages/domain/DomainAlreadyExistsPage.tsx, ensuredomainAccountIDis consistently cast as a number:const domainAccountID = Number(route.params.domainAccountID);Add the number parser for
WORKSPACES_DOMAIN_ALREADY_EXISTSinsrc/libs/Navigation/linkingConfig/config.ts:[SCREENS.WORKSPACES_DOMAIN_ALREADY_EXISTS]: { path: ROUTES.WORKSPACES_DOMAIN_ALREADY_EXISTS.route, exact: true, parse: { domainAccountID: Number, }, }, -
Handle domain requester eligibility or preserve server-returned error feedback: In
src/libs/actions/Domain.ts:582-586, when the server rejectsRequestDomainAdminship, if the backend provides a specific reason (such as user domain mismatch or validation requirement), allow the server-provided message to take precedence rather than overwriting unconditionally with the genericdomain.requestAccessError.If Expensify's product architecture dictates that accounts on public email domains (e.g. Gmail) cannot request adminship of private enterprise domains: In
DomainAlreadyExistsPage.tsx, check whether the current user's login domain is eligible to request access. If ineligible, disable the primary action and display an instructional note informing the user that admin access requests must originate from an email address matching the managed domain.
What alternative solutions did you explore? (Optional)
We explored suppressing the error banner and navigating back to ROUTES.DOMAINS_LIST optimistically regardless of API outcome; however, this would give users false confirmation that their request succeeded when it was actually rejected by the server.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
Proposal
What is the root cause of that problem?
In src/pages/domain/DomainAlreadyExistsPage.tsx:
const domainAccountID = route.params.domainAccountID;
domainAccountIDis passed as a string becausesrc/libs/Navigation/linkingConfig/config.tsconfiguresWORKSPACES_DOMAIN_ALREADY_EXISTSwithout a parameter parser (parse: {domainAccountID: Number}). When dispatched torequestDomainAdminship, passing a string accountID causes strict type mismatches in Onyx collection error key indexing (${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}).- In
src/libs/actions/Domain.ts:584,requestDomainAdminshipcatches backend rejections (such as requesting adminship for a private domain from a public email like@gmail.com) and unconditionally writes a generic fallback error into Onyx:
value: {requestAdminshipError: getMicroSecondOnyxErrorWithTranslationKey('domain.requestAccessError')}
This forces ConfirmationPageContent to render domain.requestAccessError ("We couldn't send your request. Please try again.") without indicating to the user why the request failed (e.g. email domain mismatch).
What changes do you think we should make in order to solve the problem?
- In
src/libs/Navigation/linkingConfig/config.ts: Addparse: {domainAccountID: Number}to[SCREENS.WORKSPACES_DOMAIN_ALREADY_EXISTS]sodomainAccountIDis consistently parsed into a number upon navigation. - In
src/pages/domain/DomainAlreadyExistsPage.tsx: EnsuredomainAccountIDis normalized viaNumber(route.params.domainAccountID)before passing to Onyx subscriptions andrequestDomainAdminship. - In
src/libs/actions/Domain.ts: InrequestDomainAdminship, allow server-returned error feedback infailureDatato take precedence if available, rather than overwriting unconditionally with the generic translation key. If the account is on a public domain, disable the request button or provide domain-matching guidance before dispatching the request. - Add unit test coverage in
tests/unit/DomainTest.tsverifying parameter parsing and error handling forDomainAlreadyExistsPage.
What alternative solutions did you explore? (Optional)
Silently navigating back to Domains list without checking the request result was considered, but that would falsely lead the user to believe the request succeeded when it was rejected by the server.
Proposal
Please re-state the problem that we are trying to solve in this issue.
A public-domain user tries to add a domain someone else already owns. They land on "Domain already set up" and tap Ask for admin access. Instead of being sent back to the Domains list, they get "We couldn't send your request. Please try again." Retrying never helps.
What is the root cause of that problem?
I reproduced this on staging with a gmail account against expplause.com and checked the network response. The client sends a valid request. Auth rejects it:
{
"jsonCode": 403,
"message": "403 Cannot request adminship for this domain",
"source": "auth-via-api",
"onyxData": []
}
This is the full flow and where it goes wrong:
sequenceDiagram
participant U as User (public email)
participant ADP as AddDomainPage
participant API as Web / Auth
participant Onyx
participant DAE as DomainAlreadyExistsPage
U->>ADP: enter expplause.com, Continue
ADP->>API: CreateDomain {domainName}
API-->>Onyx: generic error + form.domainAccountID + minimal domain_<id>
ADP->>DAE: navigate(domain-already-exists/:id)
Note over DAE: "Ask for admin access" is always offered,<br/>no eligibility info from CreateDomain
U->>DAE: Ask for admin access
DAE->>Onyx: optimistic domain_adminRequesters {me: 'read'}, pending ADD
DAE->>API: RequestDomainAdminship {domainAccountID}
API-->>DAE: ❌ 403 "Cannot request adminship for this domain"
Note over DAE,Onyx: failureData drops the 403 and always writes<br/>'domain.requestAccessError' ("Please try again")
Onyx-->>DAE: requestError set → stays on page, generic banner
So there are two layers:
- Auth refuses the request (403). The payload is fine.
{domainAccountID}is the same IDCreateDomainreturned, and the request reaches Auth, which rejects it. So either Auth only lets certain accounts request adminship (for example, accounts whose email is on that domain), or that check is wrong. The test case TC-917041 expects this request to succeed for a public-domain account, so Auth and the test case disagree. - The client presents a permanent rejection as something to retry.
failureDatainrequestDomainAdminship(src/libs/actions/Domain.ts) always writes the hard-codeddomain.requestAccessError. The 403 gets the same "Please try again" as a network blip, andDomainAlreadyExistsPagekeeps offering a button that can never succeed for this user.
The theory raised above, that domainAccountID arrives as a string from the route, isn't the cause. The request reaches Auth with the right ID and gets a deliberate 403.
What changes do you think we should make in order to solve the problem?
First we need someone internal to confirm the intended rule: should a user with a public-domain email be able to request adminship of an existing domain?
If yes (which is what the test case expects): the fix belongs in Auth's adminship-request check, which isn't in this repo, so it needs an internal engineer. On the App side, nothing more is needed beyond the error-handling change below. The existing success path (optimistic domain_adminRequesters, then navigating back to the Domains list) already works once Auth returns 200.
If no (the 403 is intended):
- Don't show an action that can't succeed. Have
CreateDomain's failure response include whether the user is allowed to request adminship, for example acanRequestAdminshipflag next to thedomainAccountIDit already returns. ThenDomainAlreadyExistsPagecan show only "Never mind", with a short line explaining that someone already set up this domain and to contact its admin. - Until that flag exists, handle the 403 explicitly on the client. Show a new message that doesn't offer a retry, for example "You can't request admin access to this domain. Contact one of its admins.", and disable the button after that response so the user isn't encouraged to keep tapping it.
In either case, requestDomainAdminship should stop throwing away the server's answer. Use the response's message when it's there and fall back to domain.requestAccessError only when it isn't, the same way Domain.ts already does around line 346 (response?.message ? response.message : genericError). That way a permission error in this flow never shows up as "please try again" again.
What alternative solutions did you explore? (Optional)
Navigating back to the Domains list on any response, including failures. I dropped this because the user would think a request was sent when Auth actually refused it.
Tests
tests/actions/DomainTest.ts: a 403 fromRequestDomainAdminshipproduces the non-retryable error, while a failure with no server message still falls back todomain.requestAccessError.- The optimistic
domain_adminRequesters[me]entry is rolled back on the 403, and the transient domain entry is removed whenisTransientDomainEntryis true. DomainAlreadyExistsPageUI test: after a 403 the button is disabled and the specific message is shown; on a 200 it navigates to the Domains list.
📣 @rakesh0x! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~018a48e3b960e8c0d2
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Looks like a backend issue. requesting internal Engineer to review this issue.
:ribbon: :eyes: :ribbon: C+ reviewed
Triggered auto assignment to @amyevans, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@amyevans, @parasharrajat Whoops! This issue is 2 days overdue. Let's get this updated quick!
@amyevans Huh... This is 4 days overdue. Who can take care of this?
@amyevans 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
@amyevans 10 days overdue. I'm getting more depressed than Marvin.
I confirmed it's from an intentional backend change. Have not had time to address it yet though
@amyevans @parasharrajat this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!