What’s the function of 還, 了, and 呢 in the sentence, “我還以為他不走了呢”? After many attempts to understand how the sentence is grammatically structured, I think I'll just ask here.

The sentence "我還以為他不走了呢" is from a children's book that was originally in English. I'm confused as to what the function of 還, 了, and 呢 is in this sentence. Is there some kind of sentence pattern?

The English translation of it is :I thought he'd never leave."



I found there's a "以為...呢" sentence pattern, which is used for denoting a past action that one believed to be true, but turns out to be false. Is there any other function to 呢 in this sentence?

Is 了 in this sentence acting as a sentence-end 了 (modal particle) or as a perfective aspect particle?

Does 還 indicate 'unexpectedness' or does it means 'really'? Or does it indicate/mean something else?

I found another sentence pattern, "還...呢", which is for an action that's still continuing and persisting. It could be translated as "still" added to the sentence. But that doesn't make sense to me for this particular sentence, so I don't think it's relevant in this case. 

Any help is appreciated. Thanks.
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!"