Decouple badge logic and consolidate policy loop in createTypeMenuSec…#82966
Conversation
…tions - Remove reportCounts and draftTransactions params from createTypeMenuSections - Move badge text subscriptions to local consumers (SearchTypeMenu, useSearchTypeMenu) - Extract getItemBadgeText helper to avoid duplicated badge lookup logic - Consolidate double policy iteration: getSuggestedSearchesVisibility now returns hasGroupPoliciesWithExpenseChat, eliminating redundant getGroupPaidPoliciesWithExpenseChatEnabled call - Add formatBadgeText and getItemBadgeText unit tests
|
@mkhutornyi 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios1.movios2.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb72406f23
ℹ️ 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".
src/libs/SearchUIUtils.ts
Outdated
| hasGroupPoliciesWithExpenseChat ||= | ||
| isPaidPolicy && !!policy.isPolicyExpenseChatEnabled && !policy.isJoinRequestPending && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.role; |
There was a problem hiding this comment.
Preserve delete-with-error policies in chat eligibility
This eligibility check now hard-excludes any policy with pendingAction === DELETE, but the previous logic (getGroupPaidPoliciesWithExpenseChatEnabled() via shouldShowPolicy(..., false, ...)) intentionally keeps pending-delete policies when they have errors so users can still act in recoverable states. In that failure scenario, hasGroupPoliciesWithExpenseChat becomes false and the Submit empty state can incorrectly hide the “Create expense” action even though the workspace remains accessible.
Useful? React with 👍 / 👎.
|
@szymonzalarski98 please merge main |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25e00d5a45
ℹ️ 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".
| isPaidPolicy && | ||
| !!policy.isPolicyExpenseChatEnabled && | ||
| !policy.isJoinRequestPending && | ||
| (policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || Object.keys(policy.errors ?? {}).length > 0) && |
There was a problem hiding this comment.
Preserve delete-error policies in chat-enabled check
The new hasGroupPoliciesWithExpenseChat gate now depends on Object.keys(policy.errors ?? {}).length > 0 for pending-delete policies, but useSearchTypeMenuSections maps policies without the errors field, so this expression is always false for mapped data. In the failed-delete scenario (pendingAction === DELETE with policy errors), the Submit empty state will incorrectly lose its "Create expense" button even though these policies are still meant to be visible, so users can’t start an expense from that flow.
Useful? React with 👍 / 👎.
…adge-logic-consolidate-policy-loop
|
Main merged, all comments adressed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19473431ab
ℹ️ 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".
| isPolicyExpenseChatEnabled: policy.isPolicyExpenseChatEnabled, | ||
| isJoinRequestPending: policy.isJoinRequestPending, | ||
| pendingAction: policy.pendingAction, |
There was a problem hiding this comment.
Include policy errors in mapped search policies
policyMapper now forwards pendingAction, and createTypeMenuSections relies on getSuggestedSearchesVisibility's check (pendingAction !== DELETE || Object.keys(policy.errors ?? {}).length > 0) to decide whether a workspace still counts as expense-chat-enabled. Because this mapper does not pass through errors, any paid workspace with pendingAction: DELETE but backend errors is treated as hidden, so the Submit empty state can incorrectly lose its "Create expense" button in that failure state.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19473431ab
ℹ️ 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".
|
Please check bot reviews above |
|
PR updated according to bot review, @codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.25-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.25-13 🚀
|
Explanation of Change
Fixed Issues
$ #82416
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari