In the masjid one should abstain from talking about worldly affairs, even if they are concerning things that may be permissible.
Allah (SWA) in the Holy Quran has said:
‘And the places of worship are for Allah, so invoke not any one along with Allah’. (Surah Jinn v.18)
Saaiduna Ali Radiallahu Anhu once said that “A time will come when Islam will be only for the namesake and the Quran will only be a symbol; there will be mosques but they will not resound with the praises of Allah.”
Saib Bin Yazid Radiallahu Anhu narrates that one day he was asleep in the mosque when someone threw a pebble to wake him up. He saw that it was Saaiduna Umar Radiallahu Anhu who had woken him up. Saaiduna Umar Radiallahu Anhu pointed to two men who were making noise in the mosque and asked Saib to catch hold of them and bring them to him. Accordingly he brought them to Umar Radiallahu Anhu. He asked them where they lived. They replied that they belonged to Taif. On hearing this, Umar Radiallahu Anhu said “if you had been residents of Madinah, I would have punished you for making noise in the mosque. However, I excuse you today because you have come from outside.” (Mosque in Islam p.113)
Saaiduna Umar Radialahu Anhu was very strict in this matter. He did not tolerate the slightest disrespect to the mosque. He used his whip even if he found children playing in the mosque. (Mosque in Islam p.114)
It is an act of great sin to talk about worldly matters, backbite or indulge in unnecessary and useless talks. Talking in masjid wipes out good deeds just as fire destroys wood; or as animals eat away grass. This way all virtues are destroyed totally. In a saying: A time will come on people when they will indulge in worldly talks and vain talks in masjid, so you must not sit with such people; Allah has no need for such people. (Sunan Baihaqi)
The Messenger of Allaah (peace and blessings of Allaah be upon him) said: ‘There will come a time when people will sit in circles in the mosques and they will have no concern except this world. Allaah has no need of them so do not sit with them.’”
So it is better to avoid talking about worldly matters in masjids.
There’s nothing wrong with talking about worldly matters in the masjid, as this was done by the Prophet and his companions.
It’s collected in Sahih Muslim, in the ‘Book of Masajid and Places of Prayer’ from Simaak bin Harb:
I asked Jabir bin Samurat: “Did you sit with Rasolullah?” نَعَمْ كَثِيرًا كَانَ لاَ يَقُومُ مِنْ مُصَلاَّهُ الَّذِي يُصَلِّي فِيهِ الصُّبْحَ أَوِ الْغَدَاةَ حَتَّى تَطْلُعَ الشَّمْسُ فَإِذَا طَلَعَتِ الشَّمْسُ قَامَ وَكَانُوا يَتَحَدَّثُونَ فَيَأْخُذُونَ فِي أَمْرِ الْجَاهِلِيَّةِ فَيَضْحَكُونَ وَيَتَبَسَّمُ He said: “Yes, many (times).”
He (Rasolullah) used to sit at the place where he prayed the morning (subH) prayer till the sun rose. He would stand, and they would talk about times of Jahiliya, and they would laugh while (the Prophet) only smiled.
And this narration is authentic in Sahih Muslim.
As you can read, the Prophet and his companions AT THE PLACE OF PRAYER, would talk about times of jahiliya, pre-islamic era. And they would laugh and the Prophet would smile.
This happened many times, as Jabir said he sat with Rasolullah “kathir.”
But there’s one thing you should be considerate about. Make sure you’re not disturbing others.