I had the same issue on an already installed Nextcloud instance in a VM which I upgraded to 23.
The solution I found was to Disable then Remove the Collabora app from the web interface first.
After I did this, I followed the following steps:
download https://github.com/nextcloud/richdocuments/releases/download/v4.1.2/richdocuments.tar.gz
tar xf richdocuments tar.gz
chown -R www-data:www-data richdocuments
mv richdocuments /var/www/nextcloud/apps/
Reload the web interface.
Go into the apps section and allow untested then enable Collabora Online. Make sure you DO NOT UPGRADE Collabora Online to 5.0.0.