What’s the function of 還, 了, and 呢 in the sentence, “我還以為他不走了呢”?
I am  a native speaker, but keep in mind that some native speakers suck at grammar.

呢 just adds to the tone and doesn't really mean much, but if left out in some sentences, the sentences would not sound natural. I guess you're right about the “以為‧‧‧呢” sentence pattern.

了 here indicates an action done, like the past participle tense. 不走了 means "(decided) not to leave". Interestingly, 了 can sometimes also function like the present progressive tense, too. For example, 我走了 means "I'm leaving". Therefore, I think that sentence may also be translated as "And I thought he's not leaving / decided not to leave." Note that even though 決定 (decided) isn't in the original sentence, I feel that it is not a bad translation because an action done is a decision made anyways, whether or not that decision was made consciously. Anyhow, I can probably explain it better if I know the context well.

還, as you said, indicates 'unexpectedness' in that sentence when paired with “以為‧‧‧呢”.

An example of the “還‧‧‧呢” sentence pattern used for an action that’s still continuing and persisting would be 我還在吃飯呢！ "I'm still eating!"