The performance of public transport systems varies significantly across megacities, with significant implications for urban mobility. We study the problem of optimal bus network design in Jakarta, which has the largest BRT network in the world yet low ridership. We set up a model where commuters trade off multiple bus network attributes: wait and travel time, transfers, and walking. The corresponding preference parameters influence the shape of the optimal network of routes. Empirically, we analyze the impact of four years of network expansion and a randomized bus allocation experiment, using individual ridership and commuting flows data. We measure how new bus routes and service frequency changes impact mode choice, and estimate the transit demand model using this variation. We then solve for the optimal bus network numerically. We find that commuters in Jakarta are highly sensitive to wait time and transfers, suggesting that the (utilitarian) optimal network relies on a small number of direct, high-frequency connections.