Repository: supabase/supabase
File: apps/studio/pages/new/[slug].tsx (TypeScript)

Code before:
  )

  const { data: allOverdueInvoices } = useOverdueInvoicesQuery({
    enabled: isNotOnTeamOrEnterprisePlan,
  })
  const overdueInvoices = (allOverdueInvoices ?? []).filter(
    (x) => x.organization_id === currentOrg?.id
  )
  const hasOutstandingInvoices = overdueInvoices.length > 0 && isNotOnTeamOrEnterprisePlan

  const {
    mutate: createProject,
    isLoading: isCreatingNewProject,
    isSuccess: isSuccessNewProject,
  } = useProjectCreateMutation({
    onSuccess: (res) => {
      track(
        'project_creation_simple_version_submitted',
        {
          instanceSize: form.getValues('instanceSize'),
        },
        {
          project: res.ref,
          organization: res.organization_slug,
        }
      )
      router.push(`/project/${res.ref}/building`)
    },
  })

  const { data: orgProjectsFromApi } = useOrgProjectsInfiniteQuery({ slug: currentOrg?.slug })
  const allOrgProjects = useMemo(
    () => orgProjectsFromApi?.pages.flatMap((page) => page.projects),
    [orgProjectsFromApi?.pages]
  )
  const organizationProjects =
    allProjects?.filter((project) => project.status !== PROJECT_STATUS.INACTIVE) ?? []

  const { data: _defaultRegion, error: defaultRegionError } = useDefaultRegionQuery(
    {
      cloudProvider: PROVIDERS[defaultProvider].id,
    },
    {
      enabled: !smartRegionEnabled,
      refetchOnMount: false,
      refetchOnWindowFocus: false,
      refetchInterval: false,
      refetchOnReconnect: false,
      retry: false,
    }
  )

Review comment (suggestion):
Note: We still need to pass `project` here because the project hasn't technically been created yet.

Code after:
    [currentOrg]
  )

  const { data: allOverdueInvoices } = useOverdueInvoicesQuery({
    enabled: isNotOnTeamOrEnterprisePlan,
  })
  const overdueInvoices = (allOverdueInvoices ?? []).filter(
    (x) => x.organization_id === currentOrg?.id
  )
  const hasOutstandingInvoices = overdueInvoices.length > 0 && isNotOnTeamOrEnterprisePlan

  const {
    mutate: createProject,
    isLoading: isCreatingNewProject,
    isSuccess: isSuccessNewProject,
  } = useProjectCreateMutation({
    onSuccess: (res) => {
      track(
        'project_creation_simple_version_submitted',
        {
          instanceSize: form.getValues('instanceSize'),
        },
        {
          project: res.ref,
          organization: res.organization_slug,
        }
      )
      router.push(isHomeNew ? `/project/${res.ref}` : `/project/${res.ref}/building`)
    },
  })

  const { data: orgProjectsFromApi } = useOrgProjectsInfiniteQuery({ slug: currentOrg?.slug })
  const allOrgProjects = useMemo(
    () => orgProjectsFromApi?.pages.flatMap((page) => page.projects),
    [orgProjectsFromApi?.pages]
  )
  const organizationProjects =
    allProjects?.filter((project) => project.status !== PROJECT_STATUS.INACTIVE) ?? []

  const { data: _defaultRegion, error: defaultRegionError } = useDefaultRegionQuery(
    {
      cloudProvider: PROVIDERS[defaultProvider].id,
    },
    {
      enabled: !smartRegionEnabled,
      refetchOnMount: false,
      refetchOnWindowFocus: false,
      refetchInterval: false,
      refetchOnReconnect: false,
      retry: false,
    }