When does one get credit for praying with a Minyan?
The Shulhan Aruch (O.H. 109:1) says that if one enters the synagogue (or is lagging behind in the prayer) and the congregation has reached the Amida, one may begin one’s Amida if one will be able to finish in time to respond to Kedusha (in the case of Shaharit and Minha) or Kaddish Titkabal (in the case of Arvit). If one does not believe that one would be able to finish one’s own prayer in time to respond to Kedusha or Kaddish, one should wait till the Shaliah Tzibbur reaches Kedusha or Kaddish, after which, one may begin one’s own silent Amida. Both of these scenarios ensure that one is considered to have prayed with a Minyan and gets credit, as it were, for such. Similarly, if the Minyan has already recited the Kedusha, one may begin one’s silent Amida if one will finish in time to respond to Modim. Otherwise, one should first respond to Modim and then begin one’s own Amida. If one began praying with the Minyan but prayed slowly such that one will not be able to respond to Kedusha or Kaddish, one is still considered to have prayed with a Minyan since one started on time.
Rabbi Elazar Tobo (Pekudat Elazar, § 90) writes that if one is accustomed to taking one’s time during the Amida but does not want to miss responding to Kedusha and the like, one may begin one’s silent Amida earlier than the rest of the congregation and one would still be considered to have praed with a Minyan. Rabbi Ovadia Yosef (Yabia Omer, vol. II, Orah Haim, § 7:6), citing Rabbi Avraham Gagin (Yeriot HaOhel), concurs with this approach. Similarly, Me’at Mayim (§ 21 states that as long as one starts praying at the same time as the congregation, one is considered to be praying with a Minyan.
Summary: If one is running behind in the prayer, one should only start the Amida if one will finish in time to respond to, depending on the case, Kedusha, Modim or Kadish. One may begin one’s Amida earlier than the congregation if this will ensure that one will have the opportunity to respond to the aforementioned parts of the prayer.