Brief logic is the next: after clicking on 'li' element, request is sent, and based on response value of 'contacts', it should select if it's greater than 0, once such element is find, i need to break each loop. But currently, despite I set value, which should break each loop on next iteration (returns false). count[] has been restored with old values, what's an issue?
    cy.get('div[id=company_select]').then($el => {
        const count = []
        cy.wrap($el).click().find('li').each((element, index) => {
            cy.intercept('GET', '**/company/view-json**').as('getCompanyProps')
            cy.log(count.length)
            if (count.length > 0) {
                return false
            } else {
                cy.wrap(element).click().wait('@getCompanyProps').then((interception) => {
                    if (interception.response.body.contacts.length === 0) {
                        cy.wrap($el).find('button[vs__clear]').click()
                    } else {
                        count.push(1)
                        cy.log(count.length)
                    }
                })
            }
        })
    })

 
     
    