Guard tagGroup.tags with nullish coalescing to prevent crash in Copy Policy Settings#91968
Guard tagGroup.tags with nullish coalescing to prevent crash in Copy Policy Settings#91968MelvinBot wants to merge 1 commit into
Conversation
Add ?? {} fallback when accessing tagGroup.tags in
CopyPolicySettingsSelectFeaturesPage and
WorkspaceDuplicateSelectFeaturesForm to prevent TypeError
when a tag group has no tags defined.
Co-authored-by: Chavda Sachin <ChavdaSachin@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ 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". |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@ChavdaSachin 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: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-05-28.at.8.53.55.PM.mov |
|
@mountiny, I wasn't able to find a way to reach the Onyx state where the tagGroup.tags is missing. Could we ask the QA how they reached the Onyx state from the app? |
|
@ChavdaSachin QA also does not have this, its from Sentry from normal users. Can you add unit tests that will cover this |
Explanation of Change
Adds
?? {}nullish coalescing guard ontagGroup.tagsin two files to prevent aTypeErrorcrash when a tag group has no tags defined (i.e.,tagsisnullorundefined).Object.values(tagGroup.tags)→Object.values(tagGroup.tags ?? {})?./?? 0on the result since.lengthalready returns a number when the input is guarded.This matches the defensive pattern used by 10+ other call sites in the codebase (e.g.,
PolicyUtils.ts,TagPicker,SearchQueryUtils).Fixed Issues
$ #91965
PROPOSAL: #91965 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.
Offline tests
// TODO: The human co-author must fill out offline test steps
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
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))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.AI Tests
npm run typechecknpm run lint-changednpm run prettiernpm test -- --findRelatedTestsnpm run react-compiler-compliance-checkScreenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari