diff --git a/app/src/settings_view/billing_and_usage/billing_cycle_usage_common.rs b/app/src/settings_view/billing_and_usage/billing_cycle_usage_common.rs index b75d9912a4..b2f2a149dd 100644 --- a/app/src/settings_view/billing_and_usage/billing_cycle_usage_common.rs +++ b/app/src/settings_view/billing_and_usage/billing_cycle_usage_common.rs @@ -203,14 +203,17 @@ pub fn filter_legacy_buckets(entries: &[BillingCycleUsageEntry]) -> Vec) -> bool { - entries.iter().any(|e| match &e.subject_type { - AiCreditsUsageAndCostSubjectType::Team => true, - _ => match (e.subject_uid.as_deref(), viewer_uid) { - (Some(uid), Some(viewer)) => uid != viewer, - // Unknown subject — conservatively treat as non-viewer. - _ => true, - }, - }) + entries + .iter() + .filter(|e| e.credits_used != 0 || e.cost_cents != 0) + .any(|e| match &e.subject_type { + AiCreditsUsageAndCostSubjectType::Team => true, + _ => match (e.subject_uid.as_deref(), viewer_uid) { + (Some(uid), Some(viewer)) => uid != viewer, + // Unknown subject — conservatively treat as non-viewer. + _ => true, + }, + }) } pub fn format_credits(credits: i64) -> String { diff --git a/app/src/settings_view/billing_and_usage/billing_cycle_usage_common_tests.rs b/app/src/settings_view/billing_and_usage/billing_cycle_usage_common_tests.rs index c6e16602af..407dc5b466 100644 --- a/app/src/settings_view/billing_and_usage/billing_cycle_usage_common_tests.rs +++ b/app/src/settings_view/billing_and_usage/billing_cycle_usage_common_tests.rs @@ -72,6 +72,25 @@ fn has_non_viewer_data_returns_true_for_team_aggregate_row() { assert!(has_non_viewer_data(&entries, Some(VIEWER_UID))); } +#[test] +fn has_non_viewer_data_returns_false_for_empty_team_aggregate_row() { + // The server can send a zero Team aggregate row for a solo workspace. That + // placeholder should not create the "Other members" row. + let entries = vec![ + viewer_user_entry(), + entry( + AiCreditsUsageAndCostSubjectType::Team, + None, + AiCreditsUsageAndCostType::Aggregate, + AiCreditsUsageBucket::Aggregate, + AiCreditsUsageSource::Aggregate, + 0, + 0, + ), + ]; + assert!(!has_non_viewer_data(&entries, Some(VIEWER_UID))); +} + #[test] fn has_non_viewer_data_returns_true_for_other_user_row() { // PerUserTotals / FullBreakdown emit per-user rows, so a departed teammate