The author’s wording implies that none of these five cases is valid, though the correct ruling on them has already been explained.
The sixth case: that he follows without making the intention. In this case, the one who did not intend it does not attain the reward of congregational prayer. This could occur, for example, when a person prays behind an imam whose prayer is invalid, but follows him out of embarrassment without intending to be a follower; or when he breaks his ablution while praying as a follower and is too embarrassed to leave in order to renew his ablution, so he continues along with the people, even though he did not intend to pray because he is in a state of ritual impurity. This can happen, although it is not permissible; rather, he must leave, perform ablution, and then begin the prayer anew.
The author, may Allah have mercy on him, then mentioned the types of changes in intention.
If one praying alone intends to follow an imam, his prayer is invalid …
The first type is what he mentioned in his statement: “If one praying alone intends to follow an imam, his prayer is invalid.” That is, if he changes from praying alone to following an imam, the prayer is invalid.
An example is a person who begins his prayer alone, then a group arrives and prays in congregation. If he changes from praying alone to following the imam who has arrived, his prayer is invalid, because he formed the intention to follow an imam during the prayer, and thus his intention became divided: at first he was praying alone, then he became a follower. Once the intention is divided, the prayer is invalidated, just as it would be if he changed from one obligatory prayer to another. This is the established position of the school.
The second view—reported from Ahmad—is that it is valid for one praying alone to intend to follow an imam ⦗1⦘, because the difference here concerns an attribute of the intention: initially he was praying alone, then he became a follower. It is not a change in the intention itself, and is therefore permissible. This is the correct view.