Supposedly macOS learns about your use and applies charging rules appropriately. I haven't seen it actually work in practice though, unlike Windows 11 of all things that asked me "You seem to be using this laptop mostly while connected to power, do you want to limit charging to 60% or 80% to preserve battery life?" And reminds me every month that's the case and that it can be disabled.
With an iMac that isn’t concern since it has no battery. It will last 5 years + no problem.