Mother of the Faithful, Aisha, may God be pleased with her, said, "God's Messenger, may God be pleased with him and his family, said, 'Anything invented outside the scope of our religion, by anyone, is rejected.'" Reported by Al-Bukhari and Muslim. In a report by Muslim, the text of the hadith is given as, "Any deed outside the scope of our religion, performed by anyone, is rejected."
The saying of the Prophet, may God's peace and blessings be upon him, "rejected," means invalid and inadmissible and "outside the scope of our religion," means outside of sharia.
This hadith forms one of the great foundations of the religion. It is one of the inclusive hadiths of the Chosen One, may God's peace and blessings be upon him. It is clear in rejecting every heresy and every invention in religion. This hadith can be used to invalidate all forbidden and useless contracts. This hadith has also been used by some orthodox Muslims to show that invalidation requires corruption.
The other report, "Any deed outside the scope of our religion, performed by anyone, is rejected," is clear in invalidating every heresy regardless whether it is invented by an individual or others. Some dissenters, who practice heresy, might use the first report of the hadith to claim that they didn't invent the heresy. The second report is used to invalidate their actions regardless.
This hadith should be kept, disseminated, and used to invalidate wrongful deeds for it covers all those aspects. On the other hand, deriving branches from principles that do not go outside the boundary of sunna is not heresy.
"Ibn-Daqiq's Commentary on the Nawawi Forty Hadiths" - Ibn-Daqia Al-Eid