Workflows feature disappears when going online for a workspace created offline
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: Reproducible in staging?: Needs Reproduction (Unable to reproduce) Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @FitseTLT Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
- Go offline.
- Create a new workspace.
- Reconnect to the internet.
- Open the workspace and observe the available features.
Expected Result:
The Workflows feature should remain available after the workspace syncs when the app comes back online.
Actual Result:
The Workflows feature disappears after going back online for a workspace that was created while offline.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/e9d75a3d-b68b-4b34-a08f-91abefb91b51
Issue Owner
Current Issue Owner: @QichenZhu
This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989
I can reproduce this as I am the reporter. U can assign me.
Issue Analysis
⚠️ Medium-low confidence — a live web repro attempt did not reproduce the bug (details below), so treat the root cause as the most likely mechanism, not a confirmed one.
Root cause (most likely): The "Workflows" menu item is gated solely on policy.areWorkflowsEnabled (getWorkspaceMenuItems.ts:302). That flag is only ever set optimistically on the client at creation time (Policy.ts:2801) — it is not sent as a CreateWorkspace param nor re-asserted in the command's successData (Policy.ts:2960-2988). Online, nothing re-fetches the policy so the optimistic true survives. When created offline, reconnecting fires ReconnectApp/OpenApp which pulls the authoritative policy back (App.ts:459-493); if the backend's stored copy doesn't carry areWorkflowsEnabled=true, the re-fetch overwrites the optimistic value and the item disappears.
Where the fix lives: If confirmed, the durable fix is on the backend — CreateWorkspace must derive and persist areWorkflowsEnabled (from the engagementChoice/features it already receives, mirroring the client's shouldEnableWorkflowsByDefault at Policy.ts:2738-2743) so reconnect returns the correct value. This is outside the App repo, so it needs an internal engineer with Auth/Web-Expensify access — an App-only change to successData would just be re-clobbered by the separate ReconnectApp response. The one App-side lever that could help is sending areWorkflowsEnabled as an explicit CreateWorkspace param, but that still requires the backend to read and store it.
⚠️ Reproduction was inconclusive. I drove the exact steps on dev NewDot web (create workspace while force-offline → reconnect) and Workflows stayed ON the whole time — toggle, nav item, and the fully-configured Workflows settings page all persisted after going online. This suggests the bug may be intermittent or conditional (e.g. depends on the onboarding engagement choice — shouldEnableWorkflowsByDefault is only true for no-choice / MANAGE_TEAM / LOOKING_AROUND, or on backend timing between the queued CreateWorkspace and the reconnect fetch). It's also possible the backend already persists the flag correctly, in which case the disappearance has a different trigger.
Investigation details & evidence
Client mechanism (confirmed in code):
- Menu visibility depends only on the flag —
getWorkspaceMenuItems.ts:166mapspolicy?.areWorkflowsEnabledintopolicyFeatureStates;:302renders the item only when it's truthy. - Optimistic data sets it at creation, so it correctly appears offline (
Policy.ts:2738-2801). areWorkflowsEnabledis not in theCreateWorkspaceparams, andsuccessDataonly clearspendingAction/pendingFields— note the in-code warning atPolicy.ts:2754that optimistic data must stay in sync with the API.- The field IS a real backend-persisted policy field —
enablePolicyWorkflowsround-trips it viaENABLE_POLICY_WORKFLOWS(Policy.ts:5258-5349) — soCreateWorkspacesimply isn't setting it at creation.
Open questions to confirm the mechanism (logs would help):
- Capture the
ReconnectApp/OpenAppresponseonyxDatafor the newpolicyIDright after reconnect — does it includeareWorkflowsEnabled, and withonyxMethodSET or MERGE? (A MERGE that omits the field wouldn't drop it; an overwrite implies a SET or an explicitfalse.) - Does the backend
CreateWorkspacehandler setareWorkflowsEnabledbased onengagementChoice?
Live web repro (did NOT reproduce):
More features offline: Workflows toggle ON and nav item present while offline banner is visible
More features after reconnecting: Workflows toggle still ON, nav item still present
Workflows settings page after reconnect: Submissions/Approvals/Payments fully configured
To help confirm: @FitseTLT, since you can reproduce this — what onboarding path is the account on (Manage my team's expenses, Track business, etc.), and does it happen every time? A short video capturing the reconnect + the DevTools Onyx value of policy_<id>.areWorkflowsEnabled before/after reconnect would pin down whether the server is returning it as false.
Next Steps for Contributor+ team:
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's analysis.
Because the durable fix (if confirmed) lands in the backend, please escalate to an internal engineer with Auth/Web-Expensify access rather than attempting an App-only fix.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (External)
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
I can reproduce this as I am the reporter. U can assign me.
@FitseTLT @QichenZhu i can as as well
https://github.com/user-attachments/assets/6e16ccfe-3edd-4384-86ac-4580cd12d654
Where the fix lives: If confirmed, the durable fix is on the backend
And I don't agree with Melvin. this can be fixed on FE
Precondition:
The account was created with Organize my personal spending > Household expenses onboarding flow.
Steps:
- Go to Workspaces.
- Go offline.
- Create a workspace.
- Go online.
Expected result:
The Workflows feature should have the same enabled or disabled state before and after going online.
Actual result:
The Workflows feature is enabled before going online but disabled after.
If you create a workspace online, you'll see the Workflows feature appear briefly and then disappear.
https://github.com/user-attachments/assets/ebffdae2-3ad8-417f-8952-1a8174381985
:sos: C+ Help Wanted
Proposal
What is the root cause of that problem?
When a workspace is created, buildPolicyData optimistically sets areWorkflowsEnabled: shouldEnableWorkflowsByDefault on the new policy:
https://github.com/Expensify/App/blob/0886cd3eea416af0259f86ae41393333127434b2/src/libs/actions/Policy/Policy.ts#L2801
shouldEnableWorkflowsByDefault is true for the regular “New workspace” flow, because createWorkspace defaults engagementChoice to MANAGE_TEAM when the caller doesn’t pass one:
https://github.com/Expensify/App/blob/0886cd3eea416af0259f86ae41393333127434b2/src/libs/actions/Policy/Policy.ts#L3240-L3243
So the Workflows feature and its menu item show up immediately, since the item is gated purely on that stored flag:
https://github.com/Expensify/App/blob/0886cd3eea416af0259f86ae41393333127434b2/src/pages/workspace/getWorkspaceMenuItems.ts#L166
The problem is that this “enable workflows by default” decision is computed only on the client and is never sent to the backend. The CreateWorkspaceParams we build send engagementChoice, features, areDistanceRatesEnabled, etc., but not areWorkflowsEnabled:
https://github.com/Expensify/App/blob/0886cd3eea416af0259f86ae41393333127434b2/src/libs/actions/Policy/Policy.ts#L3148-L3170
While offline this is invisible — nothing re-fetches the policy, so the optimistic true survives. But when the app reconnects, the queued CreateWorkspace is flushed and then ReconnectApp/OpenApp pulls the authoritative policy back. Because the backend created the policy without areWorkflowsEnabled set, the reconnect payload overwrites the optimistic value with a falsy one, and the Workflows menu item disappears. This is exactly why it only reproduces for a workspace created offline (creation online never triggers the reconnect re-fetch, so the optimistic value is never overwritten).
Notably, areDistanceRatesEnabled — the sibling feature computed the same way at creation — does not have this bug, precisely because it is sent as an explicit CreateWorkspace param (line 3168 above). areWorkflowsEnabled is the missing symmetric param.
What changes do you think we should make in order to solve the problem?
Send the already-computed shouldEnableWorkflowsByDefault to the backend as an explicit CreateWorkspace param, mirroring areDistanceRatesEnabled.
- Add the field to
CreateWorkspaceParamsinsrc/libs/API/parameters/CreateWorkspaceParams.ts:
areWorkflowsEnabled?: boolean;
- Include it in the
paramsobject built inbuildPolicyData(src/libs/actions/Policy/Policy.ts), right next toareDistanceRatesEnabled:
const params: CreateWorkspaceParams = {
// ...existing fields...
areDistanceRatesEnabled,
areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
personalTrackGoal,
};
With this, the backend CreateWorkspace command persists areWorkflowsEnabled (the same way it already honors areDistanceRatesEnabled), so the value returned by ReconnectApp/OpenApp matches the optimistic value and the menu item no longer disappears after the workspace syncs.
Note: this needs a small matching change in the backend CreateWorkspace handler to read and store the new param, alongside the existing areDistanceRatesEnabled handling. A purely App-side fix (e.g. re-asserting areWorkflowsEnabled in the command’s successData) will not work — successData only patches the CreateWorkspace response, whereas the field is actually overwritten by the separate ReconnectApp/OpenApp payload, which would just re-clobber it.
What alternative solutions did you explore? (Optional)
- Re-assert
areWorkflowsEnabled: shouldEnableWorkflowsByDefaultin theCreateWorkspacesuccessData. Rejected:successDatais applied to theCreateWorkspaceresponse only, not to the independentReconnectApp/OpenAppre-fetch that actually overwrites the field, so the item would still disappear after reconnect (and on any later reload/OpenApp). - Stop gating the menu item on the raw
areWorkflowsEnabledboolean and instead derive workflow visibility on the client from other persisted signals (approvalMode/autoReportingFrequency/harvesting). Rejected: it diverges from how every other feature flag ingetWorkspaceMenuItemsis read, is fragile, and doesn’t fix the underlying data — the Workflows toggle on the More features page would still show the wrong (off) state.
Proposal
What is the root cause of that problem?
The steps in the report are incomplete, which is why this reads "Unable to reproduce". The missing precondition is the account's onboarding choice. I only get the Workflows row to vanish when nvp_introSelected.choice is a track choice, and it vanishes every time then.
buildPolicyData turns Workflows on by default for a track workspace:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/actions/Policy/Policy.ts#L2738-L2743
That last predicate matters more than it looks, because TRACK_BUSINESS and TRACK_WORKSPACE are the same literal:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/CONST/index.ts#L125-L133
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/OnboardingUtils.ts#L20-L22
So the optimistic policy gets areWorkflowsEnabled: true:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/actions/Policy/Policy.ts#L2801
The request never carries that decision. features is only built when a featuresMap was supplied, and the ordinary create-workspace flow supplies none, so the param is dropped:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/actions/Policy/Policy.ts#L3143-L3146
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/actions/Policy/Policy.ts#L3166
The server therefore derives Workflows from engagementChoice alone and creates a track workspace with it off. The queued request drains on reconnect, the server copy overwrites the optimistic one, and the menu row is gated directly on the field:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/pages/workspace/getWorkspaceMenuItems.ts#L302
Here is what I watched, driving the reported steps on dev web against the production API:
- The account's
nvp_introSelected.choicewasnewDotTrackWorkspace. Offline, the newpolicy_<id>landed withareWorkflowsEnabled: trueand the Workflows row rendered. - The queued
CreateWorkspacemultipart body had nofeaturespart at all. Nothing in the request names Workflows. - Back online, the same policy read
areWorkflowsEnabled: false, whileareCategoriesEnabledandareCompanyCardsEnabledstayedtrue. Only the one flag the request never mentioned flipped. - The menu re-rendered as Overview, Members, Rooms, Reports, Categories, Distance rates, Company cards, More features. Workflows gone, no error, no toast.
An account on a non-track onboarding path gets Workflows on from the server too, so the client and server values happen to agree and nothing disappears. That is the whole reason this looks unreproducible.
flowchart TD
A["Create workspace offline, choice = newDotTrackWorkspace"] -->|"isTrackOnboardingChoice true"| B["Optimistic policy areWorkflowsEnabled true, row renders"]
B -->|"featuresMap undefined, features param dropped"| C["CreateWorkspace body has no features part"]
C --> D["Server derives Workflows from engagementChoice, track workspace gets it off"]
D -->|"server copy overwrites optimistic"| E["policy_id reads areWorkflowsEnabled false"]
E -->|"getWorkspaceMenuItems gate is falsy"| F["Workflows row disappears"]
What changes do you think we should make in order to solve the problem?
Resolve Workflows once in buildPolicyData and send that same value, so the optimistic policy and the request can never disagree. An explicit onboarding selection still wins, otherwise the existing default applies:
+const areWorkflowsEnabled = featuresMap?.find(({id}) => id === CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED)?.enabled ?? shouldEnableWorkflowsByDefault;
...
-areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
+areWorkflowsEnabled,
Then seed it as the initial value of the features reduce so the param is always present, not just when a featuresMap exists:
-const features = featuresMap?.reduce<Record<string, boolean>>((acc, feature) => {
- acc[feature.id] = !!feature.enabled;
- return acc;
-}, {});
+const features = (featuresMap ?? []).reduce<Record<string, boolean>>(
+ (acc, feature) => {
+ acc[feature.id] = !!feature.enabled;
+ return acc;
+ },
+ {[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]: areWorkflowsEnabled},
+);
-features: features ? JSON.stringify(features) : undefined,
+features: JSON.stringify(features),
I ran the same offline-create-and-reconnect flow with this in place. The request body now carries name="features" with {"areWorkflowsEnabled":true}, the policy still reads areWorkflowsEnabled: true after CreateWorkspace, ReconnectApp and OpenPolicyProfilePage have all come back, and the Workflows row is in the menu where it was before reconnect.
Two things that verification settled, both worth stating because they are easy to assume the other way:
The backend already honours this param, with no backend change. I did not touch Auth or Web-Expensify and the value round-tripped. So this does not need an internal engineer, and it does not need a new command contract.
Sending a one-key features map does not disable anything else. areCategoriesEnabled and areCompanyCardsEnabled both came back true on the created workspace, same as before the change.
The other two buildPolicyData callers benefit from the same property. createTrackedExpense builds a draft workspace with TRACK_WORKSPACE or EMPLOYER and forwards params wholesale, so it now sends the value it optimistically set. payMoneyRequest destructures a fixed subset of params and never included features, so it is unaffected either way.
For regression coverage I added a case to tests/actions/PolicyTest.ts that creates a workspace with the track engagement choice and asserts the optimistic policy and the features param agree on Workflows. It fails on current main with "Expected features to be a string", since the param is undefined there, and passes with the fix. The existing "create a new workspace with enabled workflows if the onboarding choice is newDotTrackWorkspace" test still passes, along with the rest of the file.
What alternative solutions did you explore? (Optional)
A dedicated areWorkflowsEnabled param on CreateWorkspaceParams would mirror how areDistanceRatesEnabled was fixed for this exact bug shape in 19371d3b371, and it sits right next to it in the type:
https://github.com/Expensify/App/blob/fa9e9ab9d5167326b75c86a577652ecb40e7afb9/src/libs/API/parameters/CreateWorkspaceParams.ts#L21-L23
I did not go that way because it needs the backend to start reading a key it does not read today, whereas features verifiably round-trips as it stands. Happy to switch if the team prefers the symmetry with areDistanceRatesEnabled.
Re-asserting the value in successData was the other option. It would paper over the CreateWorkspace response, but the policy I watched flip was overwritten with the server copy, so any later refresh puts it back to false. It treats the symptom and leaves the stored workspace configured wrong.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user goes offline, creates a new workspace, then reconnects and opens that workspace, the "Workflows" feature (which was enabled by default at creation time) disappears from the workspace's feature list. It should stay enabled after the workspace finishes syncing with the server.
What is the root cause of that problem?
areWorkflowsEnabled is decided entirely on the client and is never sent to the backend as part of the CreateWorkspace request. It's a locally-computed guess that only survives until the very next full refresh of that policy from the server — which is exactly what happens right after the offline→online reconnect + "open workspace" sequence in the repro steps.
In buildPolicyData (used by the real, non-draft createWorkspace path), the client computes a local default and writes it straight into the optimistic policy object:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2738-L2743
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2801
Notice that unlike the other creation-time fields (autoReporting, approvalMode, reimbursementChoice, etc.), areWorkflowsEnabled is not tracked in pendingFields, so nothing marks it as "awaiting server confirmation":
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2851-L2862
The reason this value is never confirmed is that it's simply never sent to the backend. CreateWorkspaceParams has no areWorkflowsEnabled field, and the params object built for the API call omits it entirely — it only forwards engagementChoice and, notably, areDistanceRatesEnabled (a directly analogous "client-computed default" field that was wired through to the server for this exact reason):
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/API/parameters/CreateWorkspaceParams.ts
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2799-L2801
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L3148-L3170
So the value on the server for a freshly created policy can end up not matching what the client assumed (either because the server's own default logic disagrees, or because enabling Workflows happens as a secondary/async step server-side that hasn't completed yet when the client re-syncs). Under normal online use this mismatch is rarely exposed, because nothing forces an immediate full re-fetch of that specific policy right after creation. But the repro steps guarantee exactly that re-fetch:
WorkspaceInitialPage calls openPolicyInitialPage both when the network reconnects while the page is open, and every time the page is focused (i.e. "open the workspace"):
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/pages/workspace/WorkspaceInitialPage.tsx#L143-L153
openPolicyInitialPage is a plain API.read with no client-authored successData — its Onyx updates come purely from the server's response, i.e. whatever the server considers the policy's true current state:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L5670-L5674
Because the workspace was created offline, CreateWorkspace only reaches the server once the device reconnects. The very first time the server's canonical policy record is fetched back (via that reconnect/open-triggered openPolicyInitialPage call) is therefore right after creation — and if the server's areWorkflowsEnabled doesn't match the client's optimistic guess, that merge overwrites the local true value with the server's false/unset value, which getWorkspaceMenuItems.ts reads directly to decide whether "Workflows" is shown:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/pages/workspace/getWorkspaceMenuItems.ts#L166
(A second, related path can produce the same overwrite: ReconnectApp's policyIDList is built from getNonOptimisticPolicyIDs, which excludes any policy still flagged pendingAction: ADD. Because that list is captured synchronously the instant the app detects it's back online — before the queued CreateWorkspace write has actually completed — the new workspace gets excluded from the list even after it stops being pending, so the server treats it as a policy the client "doesn't have yet" and returns its full record, which is subject to the same client/server default mismatch.)
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/App.ts#L188-L197
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Reconnect.ts#L46-L49
What changes do you think we should make in order to solve the problem?
Follow the same pattern already used for areDistanceRatesEnabled: explicitly forward the client's shouldEnableWorkflowsByDefault decision to the backend as part of the CreateWorkspace request, instead of leaving it as a value the client invents locally and hopes the server agrees with. This removes the client/server disagreement at the source, so no subsequent resync (whether triggered by openPolicyInitialPage or ReconnectApp) can silently flip the feature off.
Original: https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/API/parameters/CreateWorkspaceParams.ts
Add the field to the params type:
areDistanceRatesEnabled?: boolean;
areWorkflowsEnabled?: boolean;
Original: https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L3148-L3170
Pass the already-computed shouldEnableWorkflowsByDefault value into params:
areDistanceRatesEnabled,
areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
This is a backend-and-client contract change — CreateWorkspace on the server needs to persist areWorkflowsEnabled (and the approval/auto-reporting settings that go with it) from this new parameter instead of deriving it independently, the same way it already honors areDistanceRatesEnabled. That part requires an internal Expensify engineer to wire up on the Auth side; the App-side change above is what makes the client stop relying on an unconfirmed local guess.
As a defense-in-depth measure that's purely client-side, areWorkflowsEnabled should also be added to pendingFields in the optimistic data (next to approvalMode, autoReporting, reimbursementChoice) and cleared in successData, the way the other creation-time fields already are:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2851-L2862
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2960-L2988
This doesn't change what value ultimately wins, but it makes the field consistent with the rest of the creation-time contract and surfaces a pending/RBR state on the Workflows row instead of the value silently flipping with no visual indication while the request is in flight.
Edge cases covered:
- Draft/offline-only browsing:
createDraftInitialWorkspace/createDraftWorkspace(thePOLICY_DRAFTSvariants) are unaffected — they're purely local and never synced, so no change is needed there. isSubmitWorkspace/ other workspace types:shouldEnableWorkflowsByDefaultalready accounts forisSubmitWorkspaceand the variousengagementChoicevalues, so forwarding that single computed boolean keeps all existing call sites (createWorkspace,useAutoCreateSubmitWorkspace,useAutoCreateTrackWorkspace,useCompleteOnboarding,SettlementButton,DynamicIOURequestStepUpgrade,WorkspaceConfirmationForTravelPage) correct without touching their call sites — the value is derived once, insidebuildPolicyData.- Online creation: unaffected/still correct, since the client and server will now agree from the first request instead of only "usually" agreeing.
- Retries/failure: the new param participates in the same
optimisticData/successData/failureDatatriplet already used for the rest of the policy object, so offline retry and failure rollback behave the same as every other field in this payload. - Web vs iOS vs Android: the fix is in shared
src/libscode used by all platforms, so behavior is consistent across Windows/Chrome, macOS, and mobile.
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Create a workspace while offline: the workspace settings menu shows a Workflows row. Reconnect: as soon as the queued CreateWorkspace request is answered, the Workflows row vanishes from the same menu.
What is the root cause of that problem?
The Workflows row is driven purely by the policy's areWorkflowsEnabled flag:
https://github.com/Expensify/App/blob/8237989d6628f6ffc32200175ae32c1fbdbb4d16/src/pages/workspace/getWorkspaceMenuItems.ts#L302-L304
When a workspace is created from the "New workspace" flow, buildPolicyData computes shouldEnableWorkflowsByDefault and writes it straight into the optimistic policy as areWorkflowsEnabled. That condition treats every "track" onboarding choice (newDotTrackWorkspace, newDotTrackPersonalWorkspace, newDotPersonalSpend) as workflows-enabled:
https://github.com/Expensify/App/blob/8237989d6628f6ffc32200175ae32c1fbdbb4d16/src/libs/actions/Policy/Policy.ts#L2738-L2743
https://github.com/Expensify/App/blob/8237989d6628f6ffc32200175ae32c1fbdbb4d16/src/libs/actions/Policy/Policy.ts#L2801
The server does not agree. I captured the CreateWorkspace response on staging for an account whose onboarding choice is newDotTrackWorkspace (the manual "New workspace" flow sends exactly that as engagementChoice, see below): the response merges the full policy back with areWorkflowsEnabled: false, approvalMode: OPTIONAL, autoReportingFrequency: immediate and harvesting.enabled: false. The ReconnectApp response that follows the replayed request merges the same values. So the only field where the optimistic policy and the server disagree is areWorkflowsEnabled — the delayed-submission fields already match.
https://github.com/Expensify/App/blob/8237989d6628f6ffc32200175ae32c1fbdbb4d16/src/libs/actions/App.ts#L808
That mismatch is invisible online because the server reply lands within a second and overwrites the optimistic true before anyone opens the workspace. Offline, the optimistic true survives for the whole offline period, the user sees a Workflows row, and the same server merge then removes it on reconnect — which is the reported "disappearing" feature. Nothing is lost on reconnect; the row was never going to exist on the server-side policy.
Note that the two draft builders in the same file already use the narrower condition (no onboarding choice, newDotManageTeam, newDotLookingAround) and do not enable workflows for track choices, so buildPolicyData is the outlier:
https://github.com/Expensify/App/blob/8237989d6628f6ffc32200175ae32c1fbdbb4d16/src/libs/actions/Policy/Policy.ts#L2541-L2542
What changes do you think we should make in order to solve the problem?
In buildPolicyData, stop deriving the areWorkflowsEnabled feature flag from the same boolean that drives the delayed-submission fields. Keep shouldEnableWorkflowsByDefault exactly as it is for autoReportingFrequency, harvesting and approvalMode (the server matches those for track workspaces), but compute the optimistic areWorkflowsEnabled from the choices the server actually enables the feature for: a Submit workspace, no onboarding choice, newDotManageTeam and newDotLookingAround — i.e. the current condition minus isTrackOnboardingChoice(engagementChoice). This makes the optimistic policy match what CreateWorkspace returns, so the Workflows row is never shown for a track-choice workspace, online or offline, and nothing "disappears" on reconnect. createDraftInitialWorkspace / createDraftWorkspace already behave this way, so no change is needed there.
Update the unit test in tests/actions/PolicyTest.ts that currently asserts a newDotTrackWorkspace workspace is created with workflows enabled, so it asserts the flag is off (the sibling newDotManageTeam / newDotLookingAround assertions stay as they are).
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/99435-workflows-optimistic-mismatch?expand=1
What alternative solutions did you explore? (Optional)
If the product intent is that track workspaces should get the Workflows feature (the current App test suite assumes so), the fix belongs in the backend instead: CreateWorkspace would need to enable workflows for track engagement choices so its response returns areWorkflowsEnabled: true. In that case no App change is needed and the optimistic data is already right. Either way the fix is to make the two sides agree; re-reading the flag after reconnect or ignoring the server value on the client would just hide the disagreement.
🤖 ProposalPolice™ is tracking duplicate proposals for this issue using an OpenAI Conversation. This comment stores that Conversation's ID and can be safely ignored.
Proposal
What is the root cause of that problem?
The bug lives at the boundary between buildPolicyData and the CreateWorkspace API call. They compute feature state independently and reach different answers for areWorkflowsEnabled.
The call chain that matters. Every "New workspace" creation — online or offline — runs through:
DynamicWorkspaceConfirmationPage
→ createWorkspaceWithPolicyDraftAndNavigateToIt
→ savePolicyDraftByNewWorkspace
→ createWorkspace (no featuresMap argument)
buildPolicyData is called inside createWorkspace and derives shouldEnableWorkflowsByDefault from engagementChoice. For any track-onboarding account (newDotTrackWorkspace, newDotTrackPersonalWorkspace, newDotPersonalSpend) or the default MANAGE_TEAM choice, that value is true. It then writes it directly into the optimistic Onyx payload:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2738-L2743 https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L2797-L2807
The features param for CreateWorkspace is only populated from an explicit featuresMap argument — used exclusively by the onboarding "interested features" step:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/libs/actions/Policy/Policy.ts#L3143-L3170
The call chain above never supplies featuresMap, so params.features is undefined. The server receives no feature state and creates the policy with areWorkflowsEnabled: false. The comment at the top of buildPolicyData's optimistic block even flags this contract explicitly:
// WARNING: The data below should be kept in sync with the API...
The codebase already handles this for one feature: areDistanceRatesEnabled is computed in buildPolicyData and then explicitly forwarded as its own API param at line 3153. areWorkflowsEnabled was simply never given the same treatment.
Why it appears only offline. Online, the server reply corrects the optimistic value within milliseconds of creation — fast enough that users don't notice the blink. Offline, CreateWorkspace sits in the persisted request queue and the optimistic data is the only truth on screen for the entire session. On reconnect, two forces converge: the queued request flushes and WorkspaceInitialPage's useNetwork({onReconnect}) handler fires:
https://github.com/Expensify/App/blob/6d0c60dfd415814e3cb71508db5727bd252b3c1a/src/pages/workspace/WorkspaceInitialPage.tsx#L143-L154
The guard there is policyDraft?.id, but the draft is already cleared in optimisticData at Policy.ts:2880–2884, so the refetch is not suppressed. Both paths overwrite the optimistic areWorkflowsEnabled: true with the server's false. The Workflows row disappears while Categories and Company Cards — which the server did enable — remain. That selective disappearance is the smoking gun.
What changes do you think we should make in order to solve the problem?
Build the feature map once in buildPolicyData and use it for both the optimistic policy write and the API call, exactly as areDistanceRatesEnabled does for distance rates.
In src/libs/actions/Policy/Policy.ts, after computing areDistanceRatesEnabled (around line 2752), define a shared map:
const policyFeatures: Record<string, boolean> = {
[CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED]: true,
[CONST.POLICY.MORE_FEATURES.ARE_COMPANY_CARDS_ENABLED]: !isSubmitWorkspace,
[CONST.POLICY.MORE_FEATURES.ARE_TAGS_ENABLED]: isSubmitWorkspace,
[CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED]: areDistanceRatesEnabled,
[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]: shouldEnableWorkflowsByDefault,
};
Spread policyFeatures into the optimistic policy object (lines 2797–2807) and remove the individual boolean assignments it replaces. Features not in this map (areReportFieldsEnabled, areConnectionsEnabled, areExpensifyCardsEnabled, areInvoicesEnabled, areRulesEnabled, arePerDiemRatesEnabled) stay untouched — they are off on both sides and out of scope.
At the features param assignment (line 3143), fall back to policyFeatures when no featuresMap is provided:
const features =
featuresMap?.reduce<Record<string, boolean>>((acc, feature) => {
acc[feature.id] = !!feature.enabled;
return acc;
}, {}) ?? policyFeatures;
Keep features: JSON.stringify(features) in the params. The onboarding path is unchanged — featuresMap wins when present. Every other creation path now sends the API exactly what it rendered to the user, closing the optimistic/server divergence permanently.
What alternative solutions did you explore? (Optional)
Defaulting the optimistic value to false to match the server. Rejected: the issue's expected outcome is that Workflows remains visible after reconnect, so the correct fix is ensuring the server also enables it — not hiding it earlier on the client.
🚨 Edited by proposal-police: This proposal was edited at 2026-08-26 06:01:25 UTC.
Proposal
What is the root cause of that problem?
When an account onboarded with Organize my personal spending, Household expenses creates a workspace offline, the menu shows 8 items including Workflows and excluding Distance rates. After reconnect the count stays 8, but Workflows is gone and Distance rates appears. Creating the same workspace online flickers through the same swap.
Household expenses is a track onboarding choice. The Workspaces "New workspace" path maps any track choice to TRACK_WORKSPACE before create:
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/OnboardingUtils.ts#L14-L22
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/App.ts#L808
buildPolicyData then reuses one boolean, shouldEnableWorkflowsByDefault, for delayed submission (autoReportingFrequency, harvesting, approvalMode) and for the Workflows feature flag. Track is included, so the optimistic policy writes areWorkflowsEnabled: true:
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L2738-L2743
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L2797-L2801
Distance rates is the opposite miss. Create only turns it on for Submit workspaces or an explicit featuresMap tick, so a plain track create writes areDistanceRatesEnabled: false (and sends that same false):
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L2752
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L3168
CreateWorkspace does not agree with either optimistic value for a track workspace. It stores Workflows off and Distance rates on. Offline, only the optimistic policy is on screen. On reconnect the queued create drains, ReconnectApp / openPolicyInitialPage overwrite the policy, and the menu (gated only on those two stored flags) swaps the two rows:
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/pages/workspace/getWorkspaceMenuItems.ts#L164-L166
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/pages/workspace/getWorkspaceMenuItems.ts#L302-L311
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/pages/workspace/getWorkspaceMenuItems.ts#L326-L334
That is why the enabled count stays 8, and why Manage-team (and other non-track) accounts never reproduce it: both sides already enable Workflows and leave Distance rates off.
The draft builders already compute Workflows without the track clause, which is the value CreateWorkspace returns:
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L3297-L3298
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L3331-L3334
The optimistic true for Workflows is therefore the defect, not the server false. Delayed submission for track (immediate frequency, harvesting off) is still correct and must stay.
What changes do you think we should make in order to solve the problem?
In buildPolicyData (src/libs/actions/Policy/Policy.ts), stop using one boolean for delayed submission and the Workflows feature. Keep delayed submission on for track. Drive areWorkflowsEnabled from the same choices CreateWorkspace and createDraftWorkspace already use (Submit, no choice, Manage team, Looking around). Turn Distance rates on for track so the optimistic policy matches the server.
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L2738-L2752
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L2800-L2801
const shouldEnableWorkflowsFeature =
isSubmitWorkspace ||
!engagementChoice ||
engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ||
engagementChoice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
const shouldEnableWorkflowsByDefault = shouldEnableWorkflowsFeature || isTrackOnboardingChoice(engagementChoice);
const areDistanceRatesEnabled =
isSubmitWorkspace ||
isTrackOnboardingChoice(engagementChoice) ||
!!featuresMap?.find((feature) => feature.id === CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED && feature.enabled);
areDistanceRatesEnabled,
areWorkflowsEnabled: shouldEnableWorkflowsFeature,
areDistanceRatesEnabled is already forwarded on CreateWorkspaceParams, so the request carries the same Distance rates value the optimistic policy wrote. No new command contract.
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/src/libs/actions/Policy/Policy.ts#L3168
Offline and online then both start with Workflows off and Distance rates on for household/track. The menu no longer swaps on reconnect. Manage-team, Looking around, and Submit stay as they are.
Update tests/actions/PolicyTest.ts: the newDotTrackWorkspace case should expect Workflows off and Distance rates on, and keep delayed submission on. Add the same assertions for TRACK_PERSONAL (Household expenses).
https://github.com/Expensify/App/blob/ad957d4b6080d0ae01d3b2bf2be273bd0d3a30fd/tests/actions/PolicyTest.ts#L1267-L1292
What alternative solutions did you explore? (Optional)
Sending features: {areWorkflowsEnabled: true} (or a new areWorkflowsEnabled CreateWorkspace param) would keep Workflows after reconnect by forcing the server to match the client. That is the wrong side of the disagreement: online create already ends with Workflows off and Distance rates on, and it would not fix the Distance rates row appearing from nowhere.
Re-asserting either flag in successData only patches the CreateWorkspace response. The later ReconnectApp / openPolicyInitialPage merge still overwrites the policy with the stored server copy.
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Result
https://github.com/user-attachments/assets/3c2de49e-52f1-44ed-98a6-19a61ba3db39
Proposal
What is the root cause of that problem?
The Workflows row is gated only on the stored policy flag areWorkflowsEnabled:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/pages/workspace/getWorkspaceMenuItems.ts#L302
For a workspace made through the ordinary "New workspace" flow, buildPolicyData turns that flag on by default whenever the onboarding choice is a track/personal choice:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/actions/Policy/Policy.ts#L2738-L2743
isTrackOnboardingChoice covers TRACK_BUSINESS/TRACK_WORKSPACE, TRACK_PERSONAL and the legacy PERSONAL_SPEND, which is exactly why QichenZhu's precondition (Organize my personal spending → Household expenses) reproduces it while a Manage-team account does not:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/OnboardingUtils.ts#L14-L22
So the optimistic policy is written with areWorkflowsEnabled: true and the row renders offline:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/actions/Policy/Policy.ts#L2801
That decision never leaves the client. features is only built when a featuresMap was passed, and the plain create flow passes none, so the whole features part is dropped from the request:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/actions/Policy/Policy.ts#L3143-L3147
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/actions/Policy/Policy.ts#L3166
With nothing in the request naming Workflows, the server derives it from engagementChoice alone and stores a track workspace with the flag off (two contributors on this thread captured that response as areWorkflowsEnabled: false while areCategoriesEnabled/areCompanyCardsEnabled stayed true). Offline, the optimistic true survives the whole session; on reconnect the queued CreateWorkspace drains, the server copy overwrites the optimistic one, and the menu re-renders without the row — which is why the Workflows feature disappears when going online for a workspace created offline.
Why this is workflows-on, not workflows-off
The fix direction is contested on this thread, so it is worth settling. Track workspaces were made workflows-enabled on purpose in PR #62239 ("Make track expenses generate manual submit policies"), which added the track branch to shouldEnableWorkflowsByDefault and configured manual/immediate delayed submission for it. That intent is still enforced by a passing test asserting a newDotTrackWorkspace workspace is created with workflows enabled:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/tests/actions/PolicyTest.ts#L1267
So the optimistic true is correct; the defect is that the request never tells the server the decision the client already made. The sibling areDistanceRatesEnabled — the same "client-computed creation default" shape — does not have this bug precisely because it is sent explicitly. And the existing suite misses this because it only asserts the optimistic Onyx value, never the outgoing features param, so a dropped param is invisible to it.
What changes do you think we should make in order to solve the problem?
We need the request to carry the same workflows decision the optimistic policy made, so the two sides can never disagree. Seed the features reduce with the resolved value and always send it, in buildPolicyData:
-const features = featuresMap?.reduce<Record<string, boolean>>((acc, feature) => {
- acc[feature.id] = !!feature.enabled;
- return acc;
-}, {});
+const features = (featuresMap ?? []).reduce<Record<string, boolean>>(
+ (acc, feature) => {
+ acc[feature.id] = !!feature.enabled;
+ return acc;
+ },
+ {[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]: shouldEnableWorkflowsByDefault},
+);
-features: features ? JSON.stringify(features) : undefined,
+features: JSON.stringify(features),
Why this shape:
featuresalready round-trips through the backend today (it is what the More-features toggle sends), so no backend change is required — a new dedicated param would need the server to start reading a key it does not read yet.- Both parts are necessary. Without seeding the initial value, the param is still dropped for the plain flow. Without removing the
? :guard, the plain flow'sfeaturesMapisundefined, so the seeded map never gets stringified and nothing is sent. - Blast radius: the other
buildPolicyDatacallers arecreateTrackedExpense(forwardsparamswholesale, so it now sends what it optimistically set) andpayMoneyRequest(never includedfeatures, so unaffected). The two draft builders use a narrower default and are untouched.
Test: add a case to tests/actions/PolicyTest.ts asserting that for a track engagement choice the built features param contains areWorkflowsEnabled: true. It fails on current main (the param is undefined) and passes with the fix; the existing newDotTrackWorkspace test above still passes.
What alternative solutions did you explore? (Optional)
- A dedicated
areWorkflowsEnabledparam onCreateWorkspaceParams, mirroringareDistanceRatesEnabled:
https://github.com/Expensify/App/blob/f131d7c273a27dc30aff11698a506164aa6bc2fd/src/libs/API/parameters/CreateWorkspaceParams.ts#L21-L23
Cleaner symmetry, but the server does not read that key today, so it needs a coordinated backend change; features does not.
-
Re-assert the flag in
successData. It only patches theCreateWorkspaceresponse, not the separateReconnectApp/OpenApp merge that actually overwrites the field, so the row still vanishes on reconnect and on any later reload. -
Make the client match the server by dropping the track branch, so the row never shows for track workspaces. This inverts PR #62239's deliberate intent and the passing test above, and would hide a feature meant to be on rather than fix the disagreement.
One data point on the split between the proposals above, since it is already in the codebase.
createDraftWorkspace computes the same flag without the track clause (Policy.ts#L3297-L3298):
const shouldEnableWorkflowsByDefault =
!introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
while buildPolicyData adds || isTrackOnboardingChoice(engagementChoice) (L2738-L2743). So the two client paths already disagree for track onboarding, and the draft path is the one that matches what the server returns — which favours @wildan-m's direction over persisting the optimistic true.
@QichenZhu worth settling before a fix lands: the proposals split into "send the client's value so the server keeps it" and "stop optimistically enabling it". Those are opposite product outcomes for a track workspace, and the issue's Expected Result assumes the first. Which is intended?
Proposal
What is the root cause of that problem?
The Workflows feature is enabled client-side when creating a workspace, but that decision is never sent to the backend. When the workspace syncs after reconnecting, the server's value overwrites the client's optimistic setting.
In buildPolicyData (src/libs/actions/Policy/Policy.ts:2677-2682), the client computes shouldEnableWorkflowsByDefault:
const shouldEnableWorkflowsByDefault =
isSubmitWorkspace ||
!engagementChoice ||
engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ||
engagementChoice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND ||
isTrackOnboardingChoice(engagementChoice);
This sets areWorkflowsEnabled in the optimistic policy object (:2740):
areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
The problem: areWorkflowsEnabled is never included in the CreateWorkspace API call. CreateWorkspaceParams (src/libs/API/parameters/CreateWorkspaceParams.ts:22) has areDistanceRatesEnabled but no areWorkflowsEnabled field. The params object built at Policy.ts:3087-3108 sends areDistanceRatesEnabled (:3106) but not areWorkflowsEnabled.
When created offline, the optimistic value survives until reconnect. The moment WorkspaceInitialPage calls openPolicyInitialPage (triggered by reconnect at :246 or focus at :249), it fetches the authoritative policy from the server (Policy.ts:5615-5619). Since the backend never received areWorkflowsEnabled=true, it returns it as false or undefined, overwriting the client's optimistic true.
The Workflows menu item is gated directly on that value (WorkspaceInitialPage.tsx:208, :388):
[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]: policy?.areWorkflowsEnabled,
...
if (policyFeatureStates?.[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED] && ...)
So the item disappears the instant the server's policy replaces the optimistic one.
This only reproduces offline because online creation never triggers an immediate re-fetch, the optimistic value is never challenged.
What changes do you think we should make in order to solve the problem?
Send areWorkflowsEnabled to the backend, mirroring how areDistanceRatesEnabled is already handled.
1. Add areWorkflowsEnabled to CreateWorkspaceParams (src/libs/API/parameters/CreateWorkspaceParams.ts:22):
areDistanceRatesEnabled?: boolean;
areWorkflowsEnabled?: boolean;
personalTrackGoal?: string;
2. Include it in the params object (src/libs/actions/Policy/Policy.ts:3087-3108), right after areDistanceRatesEnabled:
const params: CreateWorkspaceParams = {
policyID,
adminsChatReportID,
expenseChatReportID,
ownerEmail: policyOwnerEmail,
makeMeAdmin,
policyName,
type: workspaceType,
adminsCreatedReportActionID,
expenseCreatedReportActionID,
customUnitID,
customUnitRateID,
engagementChoice,
currency: outputCurrency,
file: clonedFile,
companySize,
userReportedIntegration: userReportedIntegration ?? undefined,
features: features ? JSON.stringify(features) : undefined,
shouldAddGuideWelcomeMessage,
areDistanceRatesEnabled,
areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
personalTrackGoal,
};
With this, the backend persists areWorkflowsEnabled when creating the workspace (the same way it already honors areDistanceRatesEnabled), so openPolicyInitialPage's response matches the client's optimistic value and the menu item stays visible.
Note: This needs a small backend change to read and store the new param, alongside the existing areDistanceRatesEnabled handling. A frontend-only fix like re-asserting the value in successData won't work, successData only affects the CreateWorkspace response itself, not the separate openPolicyInitialPage payload that actually overwrites it.
What alternative solutions did you explore?
Re-assert in successData: Add areWorkflowsEnabled: shouldEnableWorkflowsByDefault to the CreateWorkspace command's successData. Rejected: successData patches the CreateWorkspace response only. The field is overwritten by the independent openPolicyInitialPage read that fires on reconnect, so the value would flip back to false on any reload or future openPolicyInitialPage call.
Send via features JSON: The features param already exists (:3104) and could carry {areWorkflowsEnabled: true}. One of the existing proposals suggests this path. Viable if the backend already reads features.areWorkflowsEnabled, but requires verifying the backend honors it. The dedicated param approach mirrors the working areDistanceRatesEnabled pattern exactly, so lower risk.
Proposal
What is the root cause of that problem?
The Workflows row is gated purely on the stored flag (getWorkspaceMenuItems.ts#L166):
[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]: policy?.areWorkflowsEnabled,
buildPolicyData writes that flag optimistically from shouldEnableWorkflowsByDefault (Policy.ts#L2801), and that predicate treats every track onboarding choice as workflows-enabled (L2738-L2743):
const shouldEnableWorkflowsByDefault =
isSubmitWorkspace || !engagementChoice || engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || engagementChoice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND || isTrackOnboardingChoice(engagementChoice);
That value is never transmitted. On the plain "New workspace" path no featuresMap is passed, so features is undefined and the param is dropped (L3166). The server therefore computes Workflows itself, excludes track workspaces, and the reconnect response overwrites the optimistic true with false — the row disappears. Offline only makes it visible: it is the same overwrite online, just fast enough to read as a flicker.
The codebase already says which side is wrong. createDraftWorkspace computes the same flag without the track clause (L3297-L3298):
const shouldEnableWorkflowsByDefault =
!introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
The draft path and the create path disagree for track onboarding, and the draft path is the one that agrees with the server. So the optimistic write in buildPolicyData is the defect, not the server response.
One flag, and only one, flips in every repro. All three videos on this issue show the Workflows row present offline and gone after reconnect. They disagree on a second row, which matters for scoping:
| Video | Currency | Offline | After going online |
|---|---|---|---|
| Reported (0:22 → 0:23) | ETB | Workflows | neither |
| @QichenZhu's (0:37 → 0:41) | NZD | Workflows | Distance rates |
| @mukhrr's (0:33 → 0:39) | USD | Workflows | Distance rates |
areWorkflowsEnabled is the one value that is wrong on the client in all three.
What changes do you think we should make in order to solve the problem?
Align the optimistic feature flag in buildPolicyData with createDraftWorkspace and the server: drop isTrackOnboardingChoice from what drives areWorkflowsEnabled.
Keep shouldEnableWorkflowsByDefault exactly as it is — it also drives autoReportingFrequency (L2786), approvalMode (L2787) and harvesting (L2789), where the server does match the track behaviour. Only the feature flag is wrong. Introduce a separate value next to it and use that at L2801:
const shouldEnableWorkflowsFeature = isSubmitWorkspace || !engagementChoice || engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || engagementChoice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
- areWorkflowsEnabled: shouldEnableWorkflowsByDefault,
+ areWorkflowsEnabled: shouldEnableWorkflowsFeature,
The optimistic policy then matches what CreateWorkspace returns, so there is nothing for the reconnect to overwrite. The row never appears for a track workspace rather than appearing and being taken away, which also removes the online flicker.
The existing newDotTrackWorkspace assertion in tests/actions/PolicyTest.ts expects Workflows on, so it needs to expect it off, with delayed submission (autoReportingFrequency: immediate, harvesting.enabled: false) still asserted on so the two concerns stay separated.
Compare branch: https://github.com/Expensify/App/compare/main...Abdukhamid000:App:fix/99435-track-workspace-workflows-flag?expand=1
What alternative solutions did you explore? (Optional)
Sending the client's value to the backend instead — either as an explicit CreateWorkspaceParams field mirroring areDistanceRatesEnabled (L3168) or by always seeding the features object. Both make the symptom go away, but they resolve the disagreement in favour of the client, which means track workspaces start keeping Workflows. That is a product change rather than a bug fix, and it contradicts createDraftWorkspace, which would still omit the feature. Per @QichenZhu's confirmation that removing Workflows for track is intended, this direction is the bug fix.
Also turning areDistanceRatesEnabled on for a track workspace, so the menu does not change at all on reconnect. Rejected: Distance rates appears in two of the three repros but not in the reporter's, so hardcoding track ⇒ true would show that row offline and drop it online on an ETB account — the same bug, mirrored. The client has nothing to derive it from either, since buildOptimisticDistanceRateCustomUnits writes one hardcoded MILEAGE_IRS_RATE for every currency (L2496-L2498). Whatever decides Distance rates lives on the backend and needs its own issue.