Skip to content

Part 1 - Fix review workspace settings onboarding task completion#95766

Draft
FitseTLT wants to merge 4 commits into
Expensify:mainfrom
FitseTLT:fix-review-workspace-settings-onboarding-task-completion
Draft

Part 1 - Fix review workspace settings onboarding task completion#95766
FitseTLT wants to merge 4 commits into
Expensify:mainfrom
FitseTLT:fix-review-workspace-settings-onboarding-task-completion

Conversation

@FitseTLT

@FitseTLT FitseTLT commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR adds the optimistic Onyx data that completes the "Review your workspace settings" onboarding task when a workspace setting is changed. The backend already completes the task when it processes these commands, so the client only mirrors that completion optimistically — no CompleteTask request is sent.

Wired for 10 workspace-settings commands:

WRITE_COMMAND Entry point
UPDATE_WORKSPACE_DESCRIPTION Overview → Description
UPDATE_WORKSPACE_GENERAL_SETTINGS Overview → Name, Overview → Currency
SET_WORKSPACE_AUTO_REPORTING_FREQUENCY Workflows → Report frequency
SET_WORKSPACE_AUTO_REPORTING_MONTHLY_OFFSET Workflows → Monthly offset
SET_POLICY_EXPENSE_MAX_AGE Rules → Max expense age
SET_POLICY_EXPENSE_MAX_AMOUNT Rules → Max expense amount
SET_POLICY_EXPENSE_MAX_AMOUNT_NO_RECEIPT Rules → Receipt required amount, Rules → Require receipts
SET_POLICY_BILLABLE_MODE Rules → Billable default
SET_POLICY_DEFAULT_REPORT_TITLE Reports → Default title
SET_POLICY_PREVENT_MEMBER_CREATED_TITLE Reports → Enforce title toggle, Upgrade page

Fixed Issues

$ #67648
PROPOSAL: #67648 (comment)

Tests

Precondition: sign in with an account onboarded as newDotAdmin (invited to a workspace as an admin) so the "Review your workspace settings" task exists in the onboarding/Concierge chat.

  1. Open the onboarding chat and verify "Review your workspace settings" is unchecked.
  2. Go to Workspace → Overview → Description, change the description and press Save.
  3. Return to the onboarding chat and verify the task is now checked immediately, with no app refresh.
  4. Open the Network tab and verify only the settings command is sent (e.g. UpdateWorkspaceDescription) — there must be no CompleteTask request.
  5. Verify exactly one "marked as complete" action is added to the task (no duplicates).
  6. Repeat steps 1-3 on a fresh admin-onboarded account for each remaining entry point, verifying the task completes each time:
    Overview → Name; Overview → Currency; Workflows → Report frequency; Workflows → Monthly offset; Rules → Max expense age; Rules → Max expense amount; Rules → Receipt required amount; Rules → Require receipts; Rules → Billable default; Reports → Default title; Reports → Enforce title toggle.
  7. Verify the setting itself still saves correctly in every case (no regression).
  8. No-op case: sign in with an account onboarded with any other choice (e.g. newDotManageTeam). Change a workspace setting and verify the setting saves normally and no task-completed action is created.
  9. Already-complete case: change a second workspace setting after the task is already complete. Verify the setting saves and no duplicate "marked as complete" action is added.
  10. Regression — other task flows still send CompleteTask: complete a task from the task header/preview, finish the Test Drive task, and create a workspace category/tag during onboarding. Verify each still completes and still sends its CompleteTask request.
  • Verify that no errors appear in the JS console

Offline tests

  1. Complete the precondition above, then turn off your network connection.
  2. Change any workspace setting (e.g. Overview → Description) and press Save.
  3. Verify the task is optimistically marked complete while offline.
  4. Reconnect and verify the task remains complete after the request succeeds, and that no duplicate task-completed action appears.
  5. Failure case: force the request to fail (e.g. invalid value / server error). Verify the task reverts to incomplete and the setting shows its error state.

QA Steps

Same as tests.

  • 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 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 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)
  • 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)
  • 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.
  • 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@FitseTLT
FitseTLT requested review from a team as code owners July 9, 2026 21:12
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and jayeshmangwani and removed request for a team and flaviadefaria July 9, 2026 21:12
@melvin-bot

melvin-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

@jayeshmangwani 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 July 9, 2026 21:12
@FitseTLT FitseTLT changed the title Fix review workspace settings onboarding task completion Part 1 - Fix review workspace settings onboarding task completion Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/ReportUtils.ts 86.95% <100.00%> (+0.02%) ⬆️
src/libs/actions/Policy/Policy.ts 70.53% <100.00%> (+0.62%) ⬆️
...c/pages/workspace/upgrade/WorkspaceUpgradePage.tsx 39.68% <50.00%> (+0.32%) ⬆️
src/pages/workspace/WorkspaceNamePage.tsx 0.00% <0.00%> (ø)
...ges/workspace/WorkspaceOverviewDescriptionPage.tsx 0.00% <0.00%> (ø)
...rc/pages/workspace/reports/ReportsDefaultTitle.tsx 0.00% <0.00%> (ø)
...c/pages/workspace/reports/WorkspaceReportsPage.tsx 0.00% <0.00%> (ø)
...pages/workspace/rules/RulesBillableDefaultPage.tsx 0.00% <0.00%> (ø)
...c/pages/workspace/rules/RulesMaxExpenseAgePage.tsx 0.00% <0.00%> (ø)
...ages/workspace/rules/RulesMaxExpenseAmountPage.tsx 0.00% <0.00%> (ø)
... and 6 more
... and 206 files with indirect coverage changes


function WorkspaceNamePage({policy}: Props) {
const styles = useThemeStyles();
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();

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.

❌ CONSISTENCY-3 (docs)

This exact three-line boilerplate — useCurrentUserPersonalDetails(), useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.REVIEW_WORKSPACE_SETTINGS), and then getReviewWorkspaceSettingsTaskCompletionData(reviewWorkspaceSettingsTaskInformation, currentUserAccountID) — is duplicated verbatim across 12 page components (WorkspaceNamePage, WorkspaceOverviewCurrencyPage, WorkspaceOverviewDescriptionPage, ReportsDefaultTitle, WorkspaceReportsPage, RulesBillableDefaultPage, RulesMaxExpenseAgePage, RulesMaxExpenseAmountPage, RulesReceiptRequiredAmountPage, RulesRequireReceiptsPage, WorkspaceUpgradePage, WorkspaceAutoReportingFrequencyPage, WorkspaceAutoReportingMonthlyOffsetPage). Every consumer must repeat the same wiring, and any future change to how the task-completion data is resolved has to be made in 13 places.

Extract the shared wiring into a single hook and return the ready-to-pass onyxData, so each page calls one hook:

// src/hooks/useReviewWorkspaceSettingsTaskCompletionData.ts
function useReviewWorkspaceSettingsTaskCompletionData() {
    const {accountID} = useCurrentUserPersonalDetails();
    const taskInformation = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.REVIEW_WORKSPACE_SETTINGS);
    return getReviewWorkspaceSettingsTaskCompletionData(taskInformation, accountID);
}

// in each page:
const reviewWorkspaceSettingsTaskData = useReviewWorkspaceSettingsTaskCompletionData();
...
updateGeneralSettings(policy, values.name.trim(), policy.outputCurrency, reviewWorkspaceSettingsTaskData);

Reviewed at: 56ce09d | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@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: 56ce09dba7

ℹ️ 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/libs/actions/Task.ts
hasOutstandingChildTask,
parentReportAction,
undefined,
false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Send the optimistic task action ID with completion

When a workspace-settings command succeeds for a user with this onboarding task, this path creates a local TASK_COMPLETED report action but passes shouldSendCompleteTaskRequest=false, so the completedTaskReportActionID from buildTaskData() is never sent in either CompleteTask or the settings command params. Because the backend side-effect completion that this change relies on cannot know that optimistic action ID, its returned Onyx update will use a different action while this request's successData only clears the local pending action, leaving duplicate “marked as complete” actions for the task. Please either send the optimistic action ID with the side-effect command or avoid creating a client action that the server cannot reconcile.

Useful? React with 👍 / 👎.

@FitseTLT FitseTLT Jul 9, 2026

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.

yeah @dukenv0307 I remebered this was the BE change we haven't fixed. Currently optimisitc data creates completed actions but the report action id is not communicated with the BE command for our cases here so duplicate actions are created. We will need to send the reportActionIDs from FE let me know what I should do from FE.

Full list of workspace-settings APIs (58)
POLICYCHANGELOG_UPDATE_NAME
POLICYCHANGELOG_UPDATE_DESCRIPTION
POLICYCHANGELOG_UPDATE_CURRENCY
POLICYCHANGELOG_UPDATE_FIELD
POLICYCHANGELOG_ADD_CATEGORY
POLICYCHANGELOG_UPDATE_CATEGORIES
POLICYCHANGELOG_UPDATE_CATEGORY
POLICYCHANGELOG_DELETE_CATEGORY
POLICYCHANGELOG_DELETE_CATEGORIES
POLICYCHANGELOG_SET_CATEGORY_NAME
POLICYCHANGELOG_REPLACE_CATEGORIES
POLICYCHANGELOG_ADD_TAX
POLICYCHANGELOG_UPDATE_TAX
POLICYCHANGELOG_DELETE_TAX
POLICYCHANGELOG_ADD_TAG
POLICYCHANGELOG_UPDATE_TAG
POLICYCHANGELOG_UPDATE_TAG_ENABLED
POLICYCHANGELOG_UPDATE_TAG_NAME
POLICYCHANGELOG_UPDATE_TAG_LIST
POLICYCHANGELOG_UPDATE_TAG_LIST_NAME
POLICYCHANGELOG_UPDATE_TAG_LIST_REQUIRED
POLICYCHANGELOG_DELETE_TAG
POLICYCHANGELOG_DELETE_MULTIPLE_TAGS
POLICYCHANGELOG_IMPORT_TAGS
POLICYCHANGELOG_ADD_EMPLOYEE
POLICYCHANGELOG_DELETE_EMPLOYEE
POLICYCHANGELOG_UPDATE_EMPLOYEE
POLICYCHANGELOG_UPDATE_OWNERSHIP
POLICYCHANGELOG_ADD_CUSTOM_UNIT_RATE
POLICYCHANGELOG_DELETE_CUSTOM_UNIT_RATE
POLICYCHANGELOG_UPDATE_CUSTOM_UNIT
POLICYCHANGELOG_UPDATE_CUSTOM_UNIT_RATE
POLICYCHANGELOG_UPDATE_CUSTOM_UNIT_SUB_RATE
POLICYCHANGELOG_DELETE_CUSTOM_UNIT_SUB_RATE
POLICYCHANGELOG_IMPORT_CUSTOM_UNIT_RATES
POLICYCHANGELOG_ADD_REPORT_FIELD
POLICYCHANGELOG_UPDATE_REPORT_FIELD
POLICYCHANGELOG_DELETE_REPORT_FIELD
POLICYCHANGELOG_ADD_INTEGRATION
POLICYCHANGELOG_DELETE_INTEGRATION
POLICYCHANGELOG_UPDATE_AUTOREIMBURSEMENT
POLICYCHANGELOG_UPDATE_REIMBURSEMENT_CHOICE
POLICYCHANGELOG_UPDATE_REIMBURSEMENT_ENABLED
POLICYCHANGELOG_UPDATE_MANUAL_APPROVAL_THRESHOLD
POLICYCHANGELOG_UPDATE_MAX_EXPENSE_AMOUNT
POLICYCHANGELOG_UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT
POLICYCHANGELOG_UPDATE_MAX_EXPENSE_AGE
POLICYCHANGELOG_UPDATE_DEFAULT_BILLABLE
POLICYCHANGELOG_UPDATE_DEFAULT_REIMBURSABLE
POLICYCHANGELOG_UPDATE_DEFAULT_TITLE
POLICYCHANGELOG_UPDATE_DEFAULT_TITLE_ENFORCED
POLICYCHANGELOG_UPDATE_AUTOREPORTING_FREQUENCY
POLICYCHANGELOG_UPDATE_AUTOHARVESTING
POLICYCHANGELOG_UPDATE_AUDIT_RATE
POLICYCHANGELOG_UPDATE_ACH_ACCOUNT
POLICYCHANGELOG_UPDATE_DISABLED_FIELDS
POLICYCHANGELOG_CORPORATE_UPGRADE
POLICYCHANGELOG_TEAM_DOWNGRADE
2026-07-10.00-25-36.mp4

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.

Lemme take a look

@FitseTLT
FitseTLT marked this pull request as draft July 9, 2026 21:34
@dukenv0307

Copy link
Copy Markdown
Contributor

@FitseTLT BE PRs are merged, can you please check again?

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.

2 participants