The Jordan-Hölder series for nearby cycles on some Shimura varieties and affine flag varieties