From 58c81b5b22faa80c8d1147c5a076be48b01fc226 Mon Sep 17 00:00:00 2001 From: Jordan Montgomery Date: Tue, 21 Apr 2026 11:25:42 -0400 Subject: [PATCH] Fix MDM status modal for non-ABM Apple hosts (#43850) **Related issue:** Resolves #43824 Unreleased bug so no changes file # Checklist for submitter - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters. ## Testing - [x] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results ## Summary by CodeRabbit * **Bug Fixes** * Improved DEP assignment error detection in the MDM status modal so missing data is recognized correctly, reducing spurious error messages. * Updated profile assignment visibility: the profile assignment section now appears only when relevant enrollment data is loading, has an error, or is present, preventing it from showing in inappropriate contexts. --- .../modals/MDMStatusModal/MDMStatusModal.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx index fb0958039e..5d4a04785d 100644 --- a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx +++ b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx @@ -306,9 +306,12 @@ const MDMStatusModal = ({ } if ( + // Only show the error if there is a DEP assignment error OR if the data contains the host_dep_assignment(meaning we + // expect the host to be in DEP) but there's no dep_device(meaning Apple returned nothing). If host_dep_assignment is + // not present the device isn't expected to be in DEP isDepAssignmentError || - !depAssignmentData?.host_dep_assignment || - !depAssignmentData?.dep_device + !depAssignmentData || + (depAssignmentData?.host_dep_assignment && !depAssignmentData?.dep_device) ) { return ( {renderMDMStatus()} - {isPremiumTier && isAppleDevice && renderProfileAssignment()} + {isPremiumTier && + isAppleDevice && + // Only render the profile assignment section if this host has an actual + // host_dep_assignment entry, in which case we expect there to be data to + // render. While loading or on query error, keep the section visible so + // renderProfileAssignmentList can show its spinner or DataError. + (isLoadingDepAssignment || + isDepAssignmentError || + depAssignmentData?.host_dep_assignment) && + renderProfileAssignment()} {renderFooter()} );