Install fenics 2019.1 on terminal ubuntu 22.04

Can you post the output of

apt list --installed | grep fenics
apt list --installed | grep ufl

?

I suspect that the latter is something like

python-ufl-legacy-doc/jammy,now 1:2022.3.0-2~ppa1~jammy1 all [installed,automatic]
python3-ufl-legacy/jammy,now 1:2022.3.0-2~ppa1~jammy1 all [installed,automatic]

If that is the case, then the issue is related to

Try the following

cd $HOME/.local/lib.python3.10/site-packages/cashocs
find ./ -type f -exec sed -i 's|import ufl|import ufl_legacy|g' {} \;
find ./ -type f -exec sed -i 's|ufl.Form|ufl_legacy.Form|g' {} \;
find ./ -type f -exec sed -i 's|ufl.core|ufl_legacy.core|g' {} \;
find ./ -type f -exec sed -i 's|ufl.form.Form|ufl_legacy.form.Form|g' {} \;
find ./ -type f -exec sed -i 's|ufl.replace|ufl_legacy.replace|g' {} \;
find ./ -type f -exec sed -i 's|ufl.Measure|ufl_legacy.Measure|g' {} \;
find ./ -type f -exec sed -i 's|ufl.algorithms|ufl_legacy.algorithms|g' {} \;
find ./ -type f -exec sed -i 's|ufl.log|ufl_legacy.log|g' {} \;
find ./ -type f -exec sed -i 's|ufl.Jacobian|ufl_legacy.Jacobian|g' {} \;

where I am trying to replace every instance of ufl in the code with ufl_legacy.

With these changes, I was able to run the demo you are intersted in.