It is makrooh to pray facing a person’s face
There is nothing wrong with praying behind someone who is sitting if he gives you his back; rather it is makrooh to pray facing his face, if that will distract the one who is praying.
Ibn Qudaamah (may Allah have mercy on him) said in al-Mughni (2/40):
It is makrooh to pray facing a person’s face, because ‘Umar disciplined people for doing so. According to the hadeeth of ‘Aa’ishah, the Prophet (blessings and peace of Allah be upon him) used to pray level with the middle of the bed whilst I was lying down between him and the qiblah. When I needed something, I would not want to get up facing him, so I would slip away. Agreed upon. End quote.
Al-Nawawi (may Allah have mercy on him) said in al-Majmoo‘ (3/230): It is makrooh to pray with a man or woman in front of you, facing him where you can see him. This was regarded as makrooh by ‘Umar ibn al-Khattaab and ‘Uthmaan ibn ‘Affaan (may Allah be pleased with them). And because it usually distracts one. It is also makrooh to look at what will distract one, such as a garment with decorations on it, or looking up towards the sky, and other things that are mentioned in the saheeh hadeeths. Al-Bukhaari said in his Saheeh: ‘Uthmaan (may Allah be pleased with him) regarded it as nakrooh to face a man when praying. Al-Bukhaari said: Rather that applies if one will be distracted by that, but if he will not be distracted, Zayd ibn Thaabit said: I do not mind; a man does not interrupt the prayer of another man.
With regard to one who is sitting with his back towards the one who is praying, if he does not move and distract the one who is praying, there is nothing wrong with praying behind him, just as there is nothing wrong with praying facing one who is sleeping, because of the report narrated by al-Bukhaari (382) and Muslim (512) from ‘Aa’ishah, the wife of the Prophet (blessings and peace of Allah be upon him), who said: I used to sleep in front of the Messenger of Allah (blessings and peace of Allah be upon him), with my legs in the direction of his qiblah. When he prostrated he would poke me and I would draw my legs up, and when he stood up I would stretch them out. She said: There were no lamps in the houses at that time.
And Allah knows best.