In the elseif clause whose code should have run, I replaced references to $userid with references to $_SESSION["userid"]. Since its conditional will evaluate to true only when $pass is true, $_SESSION["userid"] should always have a non-empty value whenever it is evaluated to be true. So, try accepting the invitation again.
In the elseif clause whose code should have run, I replaced references to $userid with references to $_SESSION["userid"]. Since its conditional will evaluate to true only when $pass is true, $_SESSION["userid"] should always have a non-empty value whenever it is evaluated to be true. So, try accepting the invitation again.