Skip to content

fix(team-view): hide the "Direct reports only" toggle for teams with no subteams - #197

Merged
mitasovr merged 2 commits into
mainfrom
fix/hide-noop-direct-reports-toggle
Jul 14, 2026
Merged

fix(team-view): hide the "Direct reports only" toggle for teams with no subteams#197
mitasovr merged 2 commits into
mainfrom
fix/hide-noop-direct-reports-toggle

Conversation

@mitasovr

@mitasovr mitasovr commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes constructorfabric/insight#1756. Follow-up to #192.

When a manager's reports are all direct (no subteams), scoping to direct reports can never change the roster — the toggle was a no-op that only flipped the header subtitle between "Direct reports of X" and "X's department" over the same members (visible as an (N/N) counter).

Changes

  • identity-tree.ts: new shared hasIndirectReports(roster) helper — true only when the roster contains a depth>1 report.
  • team-view-v2.tsx: the toggle and the scope subtitle render only when the team has indirect reports; otherwise the subtitle is just the member count and the full roster reaches the queries unscoped.
  • team-view.tsx (old view): the same gate on canFilterDirectReports; the IC/team IcViewToggle keeps its previous roster-only gate (hasRoster) so flat-team managers don't lose it.

Tests

  • identity-tree.test.ts: hasIndirectReports for mixed, flat, empty, and null rosters.
  • team-view-v2.test.tsx: a flat-team render asserts no switch, no scope label, and the unscoped roster reaching useTeamMembers.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements

    • The “Direct reports only” option now appears only when a team includes indirect reports.
    • Flat teams display the complete roster without showing an unnecessary toggle or department subtitle.
    • Team dashboards now consistently show the appropriate members, heatmaps, metrics, and related content when switching between direct reports and the full department.
  • Tests

    • Added coverage for nested and flat team structures, including roster filtering and toggle behavior.

…eams

When every report is direct, scoping to direct reports can never change
the roster, so the "Direct reports only" switch was a no-op that only
flipped the header label. Gate it (in both team views) on the roster
actually containing an indirect report, via a shared hasIndirectReports
helper. The old view's IC/team view toggle keeps its roster-only gate.

Fixes constructorfabric/insight#1756

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <roman.mitasov@constructor.tech>
@mitasovr
mitasovr requested a review from a team as a code owner July 14, 2026 10:54
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b4ebf6c-0e04-4f70-b8ae-8b4409086a78

📥 Commits

Reviewing files that changed from the base of the PR and between 6a02238 and 96a4e01.

📒 Files selected for processing (6)
  • src/lib/insight/identity-tree.test.ts
  • src/lib/insight/identity-tree.ts
  • src/screens/team-view-v2.test.tsx
  • src/screens/team-view-v2.tsx
  • src/screens/team-view.test.tsx
  • src/screens/team-view.tsx

📝 Walkthrough

Walkthrough

Both team dashboard variants now hide direct-report controls when a roster contains no indirect reports. A shared helper detects indirect entries, and tests cover nested teams, flat teams, empty rosters, and null rosters.

Changes

Direct-report scoping

Layer / File(s) Summary
Indirect-report detection and tests
src/lib/insight/identity-tree.ts, src/lib/insight/identity-tree.test.ts
Adds hasIndirectReports and verifies nested, flat, empty, and null roster behavior.
Team dashboard scoping
src/screens/team-view.tsx, src/screens/team-view.test.tsx
Uses indirect-report presence to control filtering while keeping roster availability separate, with tests for toggling and flat teams.
V2 dashboard scoping
src/screens/team-view-v2.tsx, src/screens/team-view-v2.test.tsx
Applies the same eligibility check to roster derivation, subtitles, toggle rendering, and flat-team coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: aleksdotbar

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main user-visible change in the team dashboard.
Linked Issues check ✅ Passed The changes hide the toggle when no indirect reports exist and keep it available when they do, covering both legacy and v2 views.
Out of Scope Changes check ✅ Passed The changes stay focused on the toggle-scoping behavior and related tests, with no unrelated features introduced.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/hide-noop-direct-reports-toggle

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mitasovr
mitasovr requested a review from aleksdotbar July 14, 2026 12:11
Covers the changed gate lines for the diff-coverage check and mirrors
the v2 screen tests: scoping on/off, and the toggle hidden for a team
with no subteams.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <roman.mitasov@constructor.tech>
@mitasovr
mitasovr merged commit 54395b2 into main Jul 14, 2026
6 checks passed
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.

Team dashboard: "Direct reports only" toggle is shown for teams with no subteams, where it does nothing

2 participants