From 0130848f6edcbb9cfddefbd6bed38e41392b2150 Mon Sep 17 00:00:00 2001 From: Magnus Jensen Date: Fri, 20 Feb 2026 18:40:31 +0200 Subject: [PATCH] show serial for fully managed android (#40184) **Related issue:** Resolves #40116 This PR also fixes a weird bug that could cause a crash on host details page, if hosts.users array was missing image # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually --- .../HostDetailsPage/HostDetailsPage.tsx | 2 +- .../details/cards/Vitals/Vitals.tests.tsx | 7 ++- .../hosts/details/cards/Vitals/Vitals.tsx | 60 +++++++++---------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index 8668107c7e..a2ce0d5215 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -669,7 +669,7 @@ const HostDetailsPage = ({ useEffect(() => { setUsersState(() => { return ( - host?.users.filter((user) => { + host?.users?.filter((user) => { return user.username .toLowerCase() .includes(usersSearchString.toLowerCase()); diff --git a/frontend/pages/hosts/details/cards/Vitals/Vitals.tests.tsx b/frontend/pages/hosts/details/cards/Vitals/Vitals.tests.tsx index 7575a03d7b..854e3135b3 100644 --- a/frontend/pages/hosts/details/cards/Vitals/Vitals.tests.tsx +++ b/frontend/pages/hosts/details/cards/Vitals/Vitals.tests.tsx @@ -9,18 +9,19 @@ import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants"; import Vitals from "./Vitals"; describe("Vitals Card component", () => { - it("renders only the device Hardware model for Android hosts that were not enrolled in MDM personally", () => { + it("renders the device Hardware model and Serial number for Android hosts that were not enrolled in MDM personally", () => { const mockHost = createMockHost({ platform: "android", hardware_model: "Pixel 6", - hardware_serial: "", + hardware_serial: "1234567890", }); render(); expect(screen.getByText("Hardware model")).toBeInTheDocument(); expect(screen.getByText("Pixel 6")).toBeInTheDocument(); - expect(screen.queryByText("Serial number")).not.toBeInTheDocument(); + expect(screen.getByText("Serial number")).toBeInTheDocument(); + expect(screen.getByText("1234567890")).toBeInTheDocument(); expect(screen.queryByText("Enrollment ID")).not.toBeInTheDocument(); expect(screen.queryByText("Private IP address")).not.toBeInTheDocument(); expect(screen.queryByText("Public IP address")).not.toBeInTheDocument(); diff --git a/frontend/pages/hosts/details/cards/Vitals/Vitals.tsx b/frontend/pages/hosts/details/cards/Vitals/Vitals.tsx index cd82c670ce..fbec323a47 100644 --- a/frontend/pages/hosts/details/cards/Vitals/Vitals.tsx +++ b/frontend/pages/hosts/details/cards/Vitals/Vitals.tsx @@ -309,38 +309,34 @@ const Vitals = ({ } // Device identity - if (!(isAndroidHost && mdm && mdm.enrollment_status !== "On (personal)")) { - if (mdm && isBYODAccountDrivenUserEnrollment(mdm.enrollment_status)) { - // Personal (BYOD) devices do not report their serial numbers, so show the enrollment id instead. - vitals.push({ - sortKey: "Enrollment ID", - element: ( - - Enrollment ID - - } - value={} - /> - ), - }); - } else { - // for all other host types, show the serial number - vitals.push({ - sortKey: "Serial number", - element: ( - - } - /> - ), - }); - } + if (mdm && isBYODAccountDrivenUserEnrollment(mdm.enrollment_status)) { + // Personal (BYOD) devices do not report their serial numbers, so show the enrollment id instead. + vitals.push({ + sortKey: "Enrollment ID", + element: ( + + Enrollment ID + + } + value={} + /> + ), + }); + } else { + // for all other host types, show the serial number + vitals.push({ + sortKey: "Serial number", + element: ( + } + /> + ), + }); } // Hardware model