Ten men combine to form a Minyan only if they are together in the same room. The Rishonim debate the question of whether a person can count toward a Minyan if he is standing in the doorway. If nine men are inside the room, and the tenth is in the doorway, do they form a Minyan, or must the tenth man come out of the doorway inside the room?
The Bet Yosef brings the view of Rashi, that the area underneath the lintel is considered part of the room, such that a person standing there counts toward the Minyan formed inside the room. By contrast, Rabbenu Yeruham (1290-1350) maintained that the area of the doorway is considered outside the room. The Bet Yosef shows that the Rambam follows Rabbenu Yeruham's view, noting the Rambam's ruling that if someone brought the meat of the Pesach sacrifice to the doorway of the home on the night of Pesach, he transgresses the Torah prohibition against bringing the meat of the sacrifice outside the home. The Rambam clearly considered the area of the doorway outside the home, and this would, presumably, apply also to the formation of a Minyan. The Shulhan Aruch accepts this view, and writes that the area of the doorway is not considered part of the room, and thus a person who stands there cannot be counted toward the Minyan.
By contrast, the Magen Abraham (Rav Avraham Gombiner, Poland, 1635-1682) cites the work Tanya Rabbati as ruling leniently, that a person in the doorway may, in fact, be counted. This is the view also of the Mishna Berura, citing the Eben Ha'ozer.
In light of these different opinions, several Poskim, including the Kaf Ha'haim (Rav Yaakob Haim Sofer, Baghdad-Jerusalem, 1870-1939), maintained that we must be stringent in both directions. This means that a person standing in the doorway of a room cannot combine with nine men in the room to form a Minyan, and also cannot combine with nine men assembled outside in the hallway, as it is uncertain whether he is considered inside the room or in the hallway. Rav Meir Mazuz (1945-2025), in Ish Masliah, writes that although it is proper to be stringent in both directions, the Halacha follows the Shulhan Aruch's ruling, and so, strictly speaking, a person standing in the doorway may combine with nine men in the hallway to form a Minyan.
Within the Shulhan Aruch's view, there is a difference of opinion regarding the status of a person standing in the area of the doorway closer to the room, such that he would be inside if the door closed. The Mishna Berura writes that according to some understandings of the Shulhan Aruch, even a person standing in this spot is considered outside, and cannot be counted toward a Minyan. This was the position also of the Kaf Ha'haim. Rav Mazuz, however, disagreed, and maintained that the person may be counted in such a case. The Mishna Berura, too, concluded that one may be lenient in this situation, even according to the Shulhan Aruch, given that many Poskim do not accept Rabbenu Yeruham's stringent view to begin with. Rav David Yosef, in Halacha Berura, likewise rules leniently, and this is the Halacha.
The Poskim debate the status of a doorway that has no door. Some argue that the only reason why the doorway would not be considered part of the room is that part of the doorway is left outside when the door is closed; therefore, if there is no door, the area of the doorway is viewed as part of the room. Others contend that to the contrary, the possibility of viewing the doorway as part of the room is based on the fact that part of the doorway is inside when the door closes. In practice, then, if there is no door, we must be stringent, and a person standing in the doorway cannot combine with people inside the room or outside the room, regardless of where in the doorway he stands.
Summary: If a person is standing in the doorway of a room, then he cannot combine with nine men inside the room to form a Minyan. Strictly speaking, he can join with nine men in the hallway outside the room to form a Minyan, though he should preferably move outside the doorway into the hallway. If he stands in the inner portion of the doorway, such that he would be inside the room if the door would close, then he can combine with nine men standing inside the room, unless there is no door, in which case he cannot combine with either those inside the room or those outside in the hall.

