Like the answer to most battery questions, it depends. Considerations for load requirements (run time), capacity margins, battery age, battery sizing, temperature, availability of the same battery model, and criticality of the loads all can play a role in your decision making on battery replacement strategies.
For example, let’s consider a hypothetical system comprised of forty VRLA batteries with a design life of ten years and a service life of five years in a UPS cabinet. If the batteries are only one year old and four are bad then replacing just the four bad units would be appropriate. But if they were 3-4 years old, then strong consideration should be given to replacing the whole string. The later the batteries are into their service life the more one should plan on replacing the entire string of batteries rather than a few cells/units, because typically as they get later in life they will all eventually start to decline in capacity. Mixing older cells/units with new is generally not a good practice when the age spread is significant, particularly if the cells/units are far along in their expected service life period.