The employer can by plan design prevent a mid-year election change from reducing your election below the amount reimbursed YTD. So if your account was overspent at the time of the event, the employer can preserve a health FSA contribution election that will reach the amount of your YTD reimbursement upon loss of eligibility.
For example, let's say you elected $1,500, and had reimbursed $1,000 with only $250 in contributions upon the loss of eligibility. The employer's cafeteria plan can require that your health FSA election be reduced no lower than to $1,000 upon the loss of eligibility. In a sense, that will be repaying the employer over the course of the year through your regular payroll contributions.
While this is somewhat of a gray area in the rules, the federal government takes the same approach for its employees in its cafeteria plan. That's a pretty good sign the IRS doesn't have an issue with it.
Note that this is different than a termination of employment situation. In that scenario, the rules are clear the employer cannot recoup any overspent amount.
More details and cites here if you're interested: https://www.newfront.com/blog/overspent-health-fsa-upon-termination-of-employment-life-event-2