diff --git a/ci/TestPatches.hs b/ci/TestPatches.hs
index cdf8d0e54e2892d9b8a357a9bb7a4caa160bb025..b0890b2a65b45f9c0096847cf1970c9c1b06e72e 100644
--- a/ci/TestPatches.hs
+++ b/ci/TestPatches.hs
@@ -359,11 +359,17 @@ failedDeps pkgs =
         failedDirectDeps <> failedTransDeps
         where
           failedTransDeps = S.unions $ map (res M.!) (S.toList $ dependencies binfo)
-          failedDirectDeps = S.filter failed (dependencies binfo)
+          failedDirectDeps = S.filter failed $ S.filter excludeSelf (dependencies binfo)
+
+          -- We don't want failures of units in the same package to count as
+          -- failed dependencies.
+          excludeSelf :: UnitId -> Bool
+          excludeSelf unitId = pkgName binfo /= pkgName binfo'
+            where (binfo', _) = pkgs M.! unitId
 
           failed :: UnitId -> Bool
-          failed uid =
-            case snd $ pkgs M.! uid of
+          failed unitId =
+            case snd $ pkgs M.! unitId of
               BuildFailed _ -> True
               _ -> False
   in res