First, add attributes app:popUpTo='your_nav_graph_id' and app:popUpToInclusive="true" to the action tag.