Weak lensing is an important technique to determine the masses of galaxy groups. However, the distortion imprint on the shape of the background galaxies is not only affected by the gravitational field of the main group, but also affected by all the mass content along the line of sight. Using COSMOS shear mock data, we study the shear profile around 165 groups and investigate the level at which the neighbouring groups can enhance or suppress the shear signal from the main halo. The mock data are based on Canada–France–Hawaii Telescope and Subaru observations, which are used to obtain the photometric redshifts of galaxies in the field and a realistic galaxy density, given by the weak-lensing distortion analysis of the observed data. We further use information on the galaxy groups (having a median mass and redshift of M200= 3.1 × 1013 M⊙ and z = 0.68, respectively) from the COSMOS X-ray catalogue of extended sources. The expected gravitational shear field of these groups is calculated assuming that the haloes are described by Navarro–Frenk–White density profiles, and the total shear is computed by summing the shear over all the lenses. We conclude that, on average, the signal-to-noise ratio for a detection of the main halo is affected by with respect to the signal-to-noise ratio the same halo would have if it was isolated in the sky. Groups with neighbours that are close in projected distance (≲1 arcmin) are the most affected, but haloes located at larger angular distances also cause a measurable shear signal. These (angular) distant groups can be interpreted as uncorrelated large-scale structure. The average bias in the mass-excess estimate of individual groups that is introduced by the external haloes is zero with an rms of ∼6–72 per cent, depending on the aperture size used. One way to eliminate this bias is by stacking the density profile of several groups. The shear signal introduced by large-scale structure acts as an external source of noise. The averaged uncertainty introduced is per component for an aperture size of θ∼ 5 arcmin, which corresponds to ∼1.8 per cent of the one-component intrinsic ellipticity value. This large-scale structure noise error becomes equal to intrinsic ellipticity noise if there are measurements for ∼3000 galaxies within a certain aperture, a number that is already achieved by current deep surveys such as COSMOS and therefore that should not be ignored.