diff --git a/products/desktop/packages/ui/src/features/loops/components/LoopsListView.test.tsx b/products/desktop/packages/ui/src/features/loops/components/LoopsListView.test.tsx index 52308d1e835a..a68ef64b5715 100644 --- a/products/desktop/packages/ui/src/features/loops/components/LoopsListView.test.tsx +++ b/products/desktop/packages/ui/src/features/loops/components/LoopsListView.test.tsx @@ -48,12 +48,11 @@ function controlledPanel(tab: HTMLElement): HTMLElement { } describe("LoopsListViewPresentation", () => { - it("does not render ownership groups while identity is loading", () => { + it("does not render visibility groups while loops are loading", () => { render( { // The triggers sit in the page header and the panels stay in the scrolling // body — one Tabs root spanning both, so switching has to keep working // across that split. - it("groups loops by ownership rather than visibility", async () => { + it("groups loops by visibility regardless of their creator", async () => { const currentUser: UserBasic = { id: 1, uuid: "current-user", @@ -81,7 +80,6 @@ describe("LoopsListViewPresentation", () => { loop("mine-team", "team"), loop("teammate-team", "team", 2), ]} - currentUserId={1} members={[currentUser]} onStartBlank={vi.fn()} onStartFromTemplate={vi.fn()} @@ -89,23 +87,23 @@ describe("LoopsListViewPresentation", () => { , ); - const personalTab = screen.getByRole("tab", { name: "My loops (2)" }); + const personalTab = screen.getByRole("tab", { name: "My loops (1)" }); expect( within(controlledPanel(personalTab)).getByText("personal loop"), ).toBeVisible(); - expect( - within(controlledPanel(personalTab)).getByText( - "team loop by current@example.com", - ), - ).toBeVisible(); - const teamTab = screen.getByRole("tab", { name: "Team loops (1)" }); + const teamTab = screen.getByRole("tab", { name: "Team loops (2)" }); await userEvent.click(teamTab); expect(teamTab).toHaveAttribute("aria-selected", "true"); expect( - within(controlledPanel(teamTab)).getByText("team loop"), + within(controlledPanel(teamTab)).getByText( + "team loop by current@example.com", + ), ).toBeVisible(); + expect( + within(controlledPanel(teamTab)).getAllByText(/team loop/), + ).toHaveLength(2); // The deselected panel is inert, then unmounts when its transition ends. await waitFor(() => expect(screen.queryByText("personal loop")).not.toBeInTheDocument(), diff --git a/products/desktop/packages/ui/src/features/loops/components/LoopsListView.tsx b/products/desktop/packages/ui/src/features/loops/components/LoopsListView.tsx index e9f4be9a66e8..4aa69ef48830 100644 --- a/products/desktop/packages/ui/src/features/loops/components/LoopsListView.tsx +++ b/products/desktop/packages/ui/src/features/loops/components/LoopsListView.tsx @@ -3,8 +3,6 @@ import type { LoopSchemas } from "@posthog/api-client/loops"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@posthog/quill"; import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events"; import type { UserBasic } from "@posthog/shared/domain-types"; -import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient"; -import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser"; import { useOrgMembers } from "@posthog/ui/features/canvas/hooks/useOrgMembers"; import { StopCloudRunDialog } from "@posthog/ui/features/sessions/components/StopCloudRunDialog"; import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent"; @@ -78,22 +76,9 @@ export function LoopsListView({ headerContent?: ReactNode; }) { const { data: loops, isLoading, isError, error } = useLoops(); - const authenticatedClient = useOptionalAuthenticatedClient(); - const { - data: currentUser, - isLoading: currentUserLoading, - isError: currentUserError, - error: currentUserQueryError, - } = useCurrentUser({ client: authenticatedClient }); const limits = useLoopLimits(); const limitReason = limits?.atLimit === true ? loopLimitReason(limits.max) : null; - let listError: unknown = null; - if (isError) { - listError = error; - } else if (currentUserError) { - listError = currentUserQueryError; - } // The standalone page names itself in-page and has no breadcrumb. When the // registry is hosted inside a space, its caller supplies that navigation @@ -147,9 +132,8 @@ export function LoopsListView({ return ( - loop.visibility === "personal" || - (currentUserId !== null && loop.created_by_id === currentUserId), - ); - const teamLoops = loops.filter( - (loop) => - loop.visibility === "team" && - (currentUserId === null || loop.created_by_id !== currentUserId), - ); + const personalLoops = loops.filter((loop) => loop.visibility === "personal"); + const teamLoops = loops.filter((loop) => loop.visibility === "team"); const createButton = (