fix: empty hosts array in filterHostsByLeadThreshold (#19343)

* return early if hosts is empty

* feedback

Co-authored-by: Alex van Andel <me@alexvanandel.com>

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Carina Wollendorfer
2025-02-18 18:19:44 +00:00
committed by GitHub
co-authored by Alex van Andel CarinaWolli
parent 6847781a7f
commit 9a271f397b
@@ -103,7 +103,7 @@ export const filterHostsByLeadThreshold = async <T extends BaseHost<BaseUser>>({
if (maxLeadThreshold === 0) {
throw new Error(errorCodes.MAX_LEAD_THRESHOLD_FALSY);
}
if (maxLeadThreshold === null) {
if (maxLeadThreshold === null || hosts.length < 1) {
return hosts; // don't apply filter.
}