Merge "Refactors common scope id setup code into utility function" into tm-mainline-prod