Solicitor's attendance at s117 meeting for patient who lacks capacity

Where a person lacks capacity and is represented by a solicitor, should that solicitor be formally invited to attend the Section 117 aftercare meeting to ensure their legal rights and best interests are upheld?

That would seem sensible to me. But then again I am not ‘everybody’, nor is everybody me.

I invite solicitors anyway even if patients are not of capacity, to S117 meetings - and some invite themselves.

If there are written rules about this, I’d like to learn more.