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()} );