So the efficiency improvement here is basically just to remove the `countBy`s in the logging, right? What I mean is, otherwise there's not a huge difference between `_.groupBy` followed by `_.contains(TYPES` and your strategy, yes?

I think your approach is a tad less transparent to read -  I'm adding a comment back at `'basal-rate-segment': alwaysTrue,` to the effect of why basals are treated differently.