Desktop environment isn't working after trying to install GNOME 40

Removing repository with sudo apt-add-repository -r ppa:shemgp/gnome-40 will not downgrade the packages to their stock versions.

You have to use ppa-purge instead.

So you have to re-add the problematic PPA by

sudo apt-add-repository ppa:shemgp/gnome-40

then install ppa-purge by

sudo apt-get install ppa-purge

and finally revert all GNOME packages to their official versions using

sudo ppa-purge ppa:shemgp/gnome-40

Then reboot.