iirc, the above snipped was added to fix another issue:
- https://github.com/kamailio/kamailio/issues/2885
Maybe it needs to be executed only in some cases, if so, then a modparam can be added to allow controlling it.
Not sure if @aalba6675 is still around to comment on it.