Answer
Excessive movement invalidates the prayer, and the criterion for excessive movement that nullifies the prayer is what the observer knows to be done by someone who is not praying. As for minimal movement, which is the opposite of excessive movement, it is excused and does not invalidate the prayer; because its origin cannot be avoided, as there are movements in a living person that are not part of the prayer by nature. Therefore, it is excused as long as it is not excessive and does not reach the limit of what can be avoided. For this reason, both intentional and forgetful actions are treated equally in this regard. Abu Qatadah (may Allah be pleased with him) reported: "The Messenger of Allah (peace be upon him) was praying while carrying Umamah bint Zainab, the daughter of the Messenger of Allah (peace be upon him) and Abu al-As ibn al-Rabi. When he stood, he would carry her, and when he prostrated, he would place her down." (Sahih Muslim 1: 385, Sahih Bukhari 1: 193). And Aisha (may Allah be pleased with her) said: "I used to sleep in front of the Messenger of Allah (peace be upon him) with my legs towards his Qiblah. When he prostrated, he would nudge me, so I would fold my legs, and when he stood, I would stretch them out." (Sahih Bukhari 1: 192, Sahih Muslim 1: 367). The nudge refers to touching or squeezing with the fingertips. See: Sharh al-Wiqayah p. 159-161, and Tabyin al-Haqaiq 1: 159-162.