Question:

Is it permissible to buy and sell in the courtyards of the masjid, while it is connected to the masjid and what is obligatory upon us towards those who we see doing the likes of that?

Answer:

What is apparent that the courtyards are not part of the masjid although it is connected to it , meaning that when the masjid gets full the people pray there, hence this (occasionally) occurs while the salaat is valid therein however it’s not part of masjid (i.e. it doesn’t apply to it the rulings of the masjid).”

The Source of Reference “Al-Fataawa al-Munawwah (8)” on min 21:41 to 22:10.

(Source)