Once someone prayed infront of me while i was laying on a sofa. It was dark at that time. Have i commited a sin? As i didnt move to the side.
There are ahadith which could be used as evidences for rulings on praying in front of a person or having a person in front of you while praying, but first let's start with a different reference from which a more general ruling can be concluded:
Once the Prophet (ﷺ) prayed on a Khamisa with marks on it and said, "The marks on it diverted my attention, take this Khamisa to Abu Jahm and bring an Inbijaniya (from him.)"
(Sahih al-Bukhari, Sahih Muslim, Sunan abi Dawood, Sunan an-Nasa'i)
From this hadith one could conclude that it is rather frowned upon to pray while having something that might disturb or distract you in front of you. This can be used as a rule of thumb for the praying person, so this is rather off-topic, as you were not praying.
Now let's take a look at the evidences we need:
- Allah's Messenger (ﷺ) used to offer his prayer (while standing) in the midst of the bed, and I used to lie in front of him between him and the Qibla If I had any necessity for getting up and I used to dislike to get up and face him (while he was in prayer), but I would gradually slip away from the bed. (Sahih al-Bukhari 1, 2 & 3 and sahih Muslim)
- It is not good that you people have made us (women) equal to dogs and donkeys. No doubt I saw Allah's Messenger (ﷺ) praying while I used to lie between him and the Qibla and when he wanted to prostrate, he pushed my legs and I withdrew them. (Sahih al-Bukhari)
- The Prophet (ﷺ) used to pray at night while I lay interposed between him and the Qibla like a corpse on the bier.
(Sahih Muslim and sunan ibn Majah)
- The Apostle of Allah (ﷺ) said his whole prayer (Tahajjud prayer) during the night while I lay between him and the Qibla. When he intended to say Witr (prayer) he awakened me and I too said witr (prayer).
(Sahih Muslim and sunan an-Nasa'i)
The ahadith above all cover the situation of a person praying while having somebody (who is not praying) between him and the qiblah. The first hadith seems to show that facing a person who is praying (looking him/her in the eyes) was considered as disliked.
The second hadith seems to show that an interaction between the praying person and a person lying in front of him is possible and there's no harm in that for neither of both.
However if the person lying or being in front of the praying person wants to leave the position they should slip away (beside the praying person not in front of him). Also see Is crossing someone while he is praying permissible?
Therefore you may find these rulings:
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.
End quote. (source islamqa #104404)
So as long as you don't look/face the praying person during the prayer there's no harm nor sin in being in front of him/her.