---
title: Hide Fantasy League Fields Without League Context
type: task
status: planned
description: >-
  Hide roster status, salary, and other fantasy league columns when user has no active league team,
  even if logged in. Thread has_league_context boolean through data-views-fields selector using
  teamId from app state.
base_uri: user:task/league/hide-fantasy-league-fields-without-league-context.md
created_at: '2026-03-06T01:04:11.050Z'
entity_id: 21bfc0d6-68c2-49cf-8cea-749908c9fd05
estimated_total_duration: 2
observations:
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
owner_identity_uri: █████████████████████████
priority: Low
public_read: true
relations:
  - >-
    relates
    [[user:task/github/mistakia/league/260-tracking-issue-for-various-data-view-errors-and-bugs.md]]
tags:
  - user:tag/league-xo-football.md
  - user:tag/software-task.md
updated_at: '2026-06-01T16:13:32.796Z'
visibility_analyzed_at: '2026-11-06T00:17:56.456Z'
---

# Implementation Plan: Hide Fantasy League Fields Without League Context

## Overview

Hide all fantasy-league fields (roster status, salary, market salary, salary-adjusted values) when there is no active league context, even if the user is logged in. Currently, `fantasy-league-table-fields.js` hides fields only when `!is_logged_in`, but they should also be hidden when the user has no team in the current league.

**Expected outcomes**:

- Fantasy league fields hidden when no league context (7 fields total)
- No change to behavior for users with an active league team
- Subsumes existing `is_logged_in` check (no login implies no teamId)

## Background

### Current Behavior

The `get_data_views_fields` selector (line 53 of `data-views-fields/index.js`) extracts `userId` from `state.getIn(['app', 'userId'])` and passes `is_logged_in: Boolean(userId)` to `PlayerTableFields`. Three field functions receive `is_logged_in`:

- `fantasy_league_table_fields({ week, is_logged_in })` -- hides all 7 fantasy league fields when `!is_logged_in` (lines 107-111)
- `player_seasonlogs_table_fields({ is_logged_in })` -- hides `player_career_year` when `!is_logged_in`
- `player_table_fields({ is_logged_in })` -- adjusts `player_name` column width (does not hide fields)

Only `fantasy_league_table_fields` needs league context gating. The other two use `is_logged_in` for unrelated purposes (a career-year field, column sizing).

### State Structure

The app reducer (`app/core/app/reducer.js`) maintains:

- `leagueId` -- defaults to `0` (from `league_defaults.LEAGUE_ID`)
- `teamId` -- defaults to `undefined`, set on AUTH_FULFILLED when user has a team, cleared on GET_TEAMS_FULFILLED if team no longer exists

### Signal for League Context

`teamId` is the strongest signal. If `teamId` is falsy, the user does not have a team in the currently active league, making all fantasy-league fields meaningless. `leagueId` is not suitable because its default value of `0` is a valid public league ID.

### Existing Defensive Handling

The data-views component (`data-views.js`) already strips `player_league_roster_status` from `prefix_columns` when `leagueId` is not set (lines 222-249). The data-views reducer adds `player_league_roster_status` to prefix_columns on AUTH_FULFILLED when the user has leagues. These mechanisms handle the prefix column but do not prevent other fantasy league fields from appearing in the column picker.

### Component Behavior Without Context

`PlayerRowStatusColumn` gracefully degrades without league context -- it shows 'FA' for all players rather than erroring. The primary benefit of this change is UX cleanliness (removing meaningless columns from the picker) rather than error prevention.

## Design

Thread a `has_league_context` boolean through the selector chain to `fantasy_league_table_fields` only:

- In `get_data_views_fields`, add `teamId` as an input selector and derive `has_league_context: Boolean(teamId)`
- Pass `has_league_context` through `PlayerTableFields` to `fantasy_league_table_fields`
- In `fantasy_league_table_fields`, replace `is_logged_in` with `has_league_context` in the hiding condition
- Leave the other three field functions unchanged -- they gate on `is_logged_in` for non-league reasons

### Edge Cases

- **Saved views with fantasy columns**: The `hidden` flag on field definitions prevents columns from appearing in the column picker (react-table filters them from `memoized_visible_columns`). The existing `filtered_table_state` memos in `data-views.js` already strip `player_league_roster_status` from `prefix_columns` when no `leagueId`. No additional handling needed.
- **Server-side query**: The column definition defaults `lid = 1`, but since the column won't be requested when hidden, no server change is needed.
- **Selector memoization**: `createSelector` will re-evaluate when `teamId` changes in app state, correctly updating field visibility.

## Notes

- `teamId` is preferred over `leagueId` because `leagueId` defaults to `0` (a valid public league). A user can have `leagueId: 0` but no team in that league
- `is_logged_in` can be removed from `fantasy_league_table_fields` parameters since `!has_league_context` subsumes it
- `projected_table_fields` contains `points_added` fields in the `FANTASY_LEAGUE` column group that are not gated on login or league context -- this is a separate concern out of scope for this task
- No backend changes needed -- this is purely frontend field visibility
- No existing tests cover this code path

## Plan

### Core Implementation

- [ ] **Add teamId input selector to `get_data_views_fields`**
  - File: `repository/active/league/app/core/data-views-fields/index.js`
  - Purpose: Extract `teamId` from app state and derive `has_league_context`
  - Changes:
    - Add input selector: `(state) => state.getIn(['app', 'teamId'])`
    - Update result function signature to accept `teamId` parameter
    - Pass `has_league_context: Boolean(teamId)` to `PlayerTableFields`

- [ ] **Thread has_league_context through PlayerTableFields**
  - File: `repository/active/league/app/core/data-views-fields/index.js`
  - Purpose: Forward the flag to `fantasy_league_table_fields` only
  - Changes:
    - Add `has_league_context` to `PlayerTableFields` destructured parameters
    - Pass `has_league_context` to `fantasy_league_table_fields` call
    - Leave other field function calls unchanged

- [ ] **Replace is_logged_in with has_league_context in fantasy_league_table_fields**
  - File: `repository/active/league/app/core/data-views-fields/fantasy-league-table-fields.js`
  - Purpose: Hide fields based on league context instead of login status
  - Changes:
    - Replace `is_logged_in` with `has_league_context` in destructured parameter
    - Change condition from `if (!is_logged_in)` to `if (!has_league_context)`

### Validation

- [ ] **Verify field visibility across user contexts**
  - Not logged in: all fantasy league fields hidden (has_league_context is false)
  - Logged in, no league team: all fantasy league fields hidden (teamId is falsy)
  - Logged in, in league with team: all fantasy league fields visible (teamId is truthy)
  - Column picker should not show fantasy league fields when hidden
