Do not fetch owned paths if there's no valid account

Additionally, fall back to account_id if account.email is not set.

Release-Notes: skip
Change-Id: Ia696727118d4dc4e0b764d81633ccb9e90e0aa4f
diff --git a/web/code-owners-api.ts b/web/code-owners-api.ts
index 109de1a..0039563 100644
--- a/web/code-owners-api.ts
+++ b/web/code-owners-api.ts
@@ -195,8 +195,11 @@
    * Returns a promise fetching which files are owned by a given user.
    */
   listOwnedPaths(changeId: NumericChangeId, account: AccountInfo) {
+    if (!account.email && !account._account_id)
+      return Promise.resolve(undefined);
+    const user = account.email ?? account._account_id;
     return this.get(
-      `/changes/${changeId}/revisions/current/owned_paths?user=${account.email}&limit=10000`
+      `/changes/${changeId}/revisions/current/owned_paths?user=${user}&limit=10000`
     ) as Promise<OwnedPathsInfo>;
   }
 
@@ -317,7 +320,7 @@
     if (!account) return undefined;
     return this.fetchOnce('listOwnedPaths', () =>
       this.codeOwnerApi.listOwnedPaths(this.change._number, account)
-    ) as Promise<OwnedPathsInfo>;
+    ) as Promise<OwnedPathsInfo | undefined>;
   }
 
   getBranchConfig(): Promise<CodeOwnerBranchConfigInfo> {