Yep, that is allowed
Nothing in the rules for the monk's Deflect Missiles feature prevents this sequence of events from working as you describe:
Starting at 3rd level, you can use your reaction to deflect or catch
the missile when you are hit by a ranged weapon attack. When you
do so, the damage you take from the attack is reduced by 1d10 + your
Dexterity modifier + your monk level.
If you reduce the damage to 0, you can catch the missile if it is
small enough for you to hold in one hand and you have at least one
hand free. If you catch a missile in this way, you can spend 1 ki
point to make a ranged attack with the weapon or piece of ammunition
you just caught, as part of the same reaction. You make this attack
with proficiency, regardless of your weapon proficiencies, and the
missile counts as a monk weapon for the attack, which has a normal
range of 20 feet and a long range of 60 feet.
It can be used exactly as you described. Any incoming missile, as long as it is from a ranged weapon attack and hits you, can be deflected. Bonus points for creativity :)
It is kinda expensive though; it expends an attack for your ally, and a reaction and a ki point for you to achieve. It also comes with the risk of simply getting shot if the ranged ally rolls well on the damage roll and you roll badly on the damage reduction from Deflect Missiles.
Just remember that it doesn't work with ranged spell attacks, before you get the party wizard to chuck magic stones at you.