Remove isPolicyExpenseChatEnabled from PolicyUtils.ts helpers#93588
Remove isPolicyExpenseChatEnabled from PolicyUtils.ts helpers#93588fedirjh wants to merge 8 commits into
isPolicyExpenseChatEnabled from PolicyUtils.ts helpers#93588Conversation
This is PR A1 of the isPolicyExpenseChatEnabled removal plan. All isPolicyExpenseChatEnabled checks in App are already paired with isPaidGroupPolicy() or equivalent, making the flag redundant. Changes: - getActivePoliciesWithExpenseChat(): Remove isPolicyExpenseChatEnabled from filter, keep other conditions (pendingAction, name, id, role) - canSubmitPerDiemExpenseFromWorkspace(): Remove isPolicyExpenseChatEnabled, keep perDiem checks only - getDefaultChatEnabledPolicy(): Remove isPolicyExpenseChatEnabled, keep isGroupPolicy() check Issue: Expensify/Expensify#370320
This is PR A1 of the isPolicyExpenseChatEnabled removal plan. The isPolicyExpenseChatEnabled flag was always true for paid group policies (TEAM/CORPORATE), making it redundant when used alongside policy type checks. Changes: - getActivePoliciesWithExpenseChat(): Replace isPolicyExpenseChatEnabled with isPaidGroupPolicy() to maintain the same semantic meaning - canSubmitPerDiemExpenseFromWorkspace(): Remove isPolicyExpenseChatEnabled, perDiem checks are sufficient (only Control policies have per diem units) - getDefaultChatEnabledPolicy(): Remove isPolicyExpenseChatEnabled, keep isGroupPolicy() check Issue: Expensify/Expensify#370320
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0846d8fe8
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Combines PR A1 and A2 changes: - getGroupPaidPoliciesWithExpenseChatEnabled(): Renamed to getGroupPaidPolicies() and removed isPolicyExpenseChatEnabled (isPaidGroupPolicy is sufficient) - getGroupPoliciesWhereReportCanBeCreated(): Removed isPolicyExpenseChatEnabled, kept isPaidGroupPolicy and canAccessSubmitWorkspaceFeatures checks Updated all usages of the renamed function in: - IOURequestStepDistanceRate.tsx - SplitExpenseEditPage.tsx - ProductTrainingContext/index.tsx - SplitExpenses.ts
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Address review feedback: Instead of just checking isGroupPolicy, verify that activePolicy is actually in the groupPoliciesWithChatEnabled list to ensure it passes the same filtering criteria as the callers.
isPolicyExpenseChatEnabled from PolicyUtils.ts helpers
Submit policies don't have isPolicyExpenseChatEnabled=true, so use isPaidGroupPolicy (TEAM/CORPORATE only) instead of isGroupPolicy to maintain the original behavior.
Maintain original isPolicyExpenseChatEnabled behavior by adding isPaidGroupPolicy check alongside the perDiem unit checks.
Extract hasAnyPaidPolicy() helper to simplify boolean checks for whether user has any paid workspaces. Use it in: - SplitExpenseEditPage.tsx - ProductTrainingContext/index.tsx
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21474e2c8c
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Address review feedback: the membership check broke the FAB Create report caller, which truncates groupPoliciesWithChatEnabled to 2 entries. Validate the active policy directly via isPaidGroupPolicy instead, which preserves the original isPolicyExpenseChatEnabled semantics (TEAM/CORPORATE only) and avoids the truncated-list edge case.
|
No product review needed |
isPolicyExpenseChatEnabled from PolicyUtils.ts helpersisPolicyExpenseChatEnabled from PolicyUtils.ts helpers
Explanation of Change
This is PR A1 of the
isPolicyExpenseChatEnabledremoval plan from https://github.com/Expensify/Expensify/issues/370320.All
isPolicyExpenseChatEnabledchecks in App are already paired withisPaidGroupPolicy()or equivalent, making the flag redundant. This PR removes the flag from 3 simple helper functions inPolicyUtils.ts:getActivePoliciesWithExpenseChat()- RemovedisPolicyExpenseChatEnabledfrom filter, keeping other conditions (pendingAction,name,id,getPolicyRole)canSubmitPerDiemExpenseFromWorkspace()- RemovedisPolicyExpenseChatEnabled, keeping perDiem checks onlygetDefaultChatEnabledPolicy()- RemovedisPolicyExpenseChatEnabled, keepingisGroupPolicy()checkFixed Issues
$ Part of https://github.com/Expensify/Expensify/issues/370320
Tests
Prerequisites:
+in email (e.g.,yourname+test1@gmail.com) to mark it as a test accountTest 1: Create an Expense — Choose recipient (Personal / self-DM vs. Workspace)
$25.00) on the Manual tab and tap NextTest 1b: Create Expense — Submit to a workspace
Test 1c: Create Expense — Per Diem recipient filtering
Test 2: Per Diem Expense
Setup: On a Corporate workspace, go to Settings → Workspaces → [workspace] → Per diem, enable Per diem, and add a rate (e.g., "Daily",
$100).Test 2b: Per Diem — no eligible workspace
Test 3: Time Tracking
Setup: On a Corporate workspace, go to Settings → Workspaces → [workspace] → Time and enable Time tracking.
2 hours), add a description, and create the expenseTest 4: Split Expense
$50.00) and select participantsTest 5: Change Expense Workspace
Offline tests
N/A - This PR removes redundant checks; offline behavior is unchanged.
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - No UI changes
Android: mWeb Chrome
N/A - No UI changes
iOS: Native
N/A - No UI changes
iOS: mWeb Safari
N/A - No UI changes
MacOS: Chrome / Safari
N/A - No UI changes