Removing the mainsite from My sites link

Hi,

Can you provide me a mu-plugin to remove the main site under the 'My Sites' parent menu from both font end and back end of all the sub sites.

I have used this code to remove the main site under my sites menu https://gist.github.com/sjaved87/11b514769cd159a23c582a4aa4a3befb but for some reason on the front end of the site it still displays.

Appreciate any help.
Thanks.