Correctly handle hash orders when limiting reflections [4-0-stable]

NOTE: PR against 4-0-stable.

Fixes #15405. The behavior in that issue occurs on any version prior to f83c9b10b4c92b0d8deacb30d6fdfa2b1252d6dd, so 4.1.0 and up are not affected.