Buggy code:
public class CensusFormPayloadBuilders { private static void addNewLocationPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { } private static void addNewIndividualPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { } public static class AddLocation implements FormPayloadBuilder { @ Override public void buildFormPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { PayloadTools . addMinimalFormPayload ( formPayload , navigateActivity ) ; PayloadTools . flagForReview ( formPayload , false ) ; CensusFormPayloadBuilders . addNewLocationPayload ( formPayload , navigateActivity ) ; } } public static class EvaluateLocation implements FormPayloadBuilder { @ Override public void buildFormPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { PayloadTools . addMinimalFormPayload ( formPayload , navigateActivity ) ; PayloadTools . flagForReview ( formPayload , false ) ; String locationExtId = navigateActivity . getHierarchyPath ( ) . get ( HOUSEHOLD_STATE ) . getExtId ( ) ; String locationUuid = navigateActivity . getHierarchyPath ( ) . get ( HOUSEHOLD_STATE ) . getUuid ( ) ; formPayload . put ( LOCATION_EXTID , locationExtId ) ; formPayload . put ( LOCATION_UUID , locationUuid ) ; formPayload . put ( ENTITY_EXTID , locationExtId ) ; formPayload . put ( ENTITY_UUID , locationUuid ) ; } } public static class AddMemberOfHousehold implements FormPayloadBuilder { @ Override public void buildFormPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { PayloadTools . addMinimalFormPayload ( formPayload , navigateActivity ) ; PayloadTools . flagForReview ( formPayload , false ) ; CensusFormPayloadBuilders . addNewIndividualPayload ( formPayload , navigateActivity ) ; ContentResolver resolver = navigateActivity . getContentResolver ( ) ; SocialGroupGateway socialGroupGateway = new SocialGroupGateway ( ) ; SocialGroup socialGroup = socialGroupGateway . getFirst ( resolver , socialGroupGateway . findByLocationUuid ( navigateActivity . getCurrentSelection ( ) . getUuid ( ) ) ) ; IndividualGateway individualGateway = new IndividualGateway ( ) ; <START_BUG> Individual headOfHousehold = individualGateway . getFirst ( resolver , individualGateway . findByExtIdPrefixDescending ( socialGroup . getGroupHeadUuid ( ) ) ) ; <END_BUG> if ( ( null != ( headOfHousehold . getPhoneNumber ( ) ) ) && ( ! ( headOfHousehold . getPhoneNumber ( ) . isEmpty ( ) ) ) ) { formPayload . put ( POINT_OF_CONTACT_NAME , Individual . getFullName ( headOfHousehold ) ) ; formPayload . put ( POINT_OF_CONTACT_PHONE_NUMBER , headOfHousehold . getPhoneNumber ( ) ) ; } else { formPayload . put ( POINT_OF_CONTACT_NAME , headOfHousehold . getPointOfContactName ( ) ) ; formPayload . put ( POINT_OF_CONTACT_PHONE_NUMBER , headOfHousehold . getPointOfContactPhoneNumber ( ) ) ; } formPayload . put ( RELATIONSHIP_UUID , IdHelper . generateEntityUuid ( ) ) ; formPayload . put ( MEMBERSHIP_UUID , IdHelper . generateEntityUuid ( ) ) ; formPayload . put ( SOCIALGROUP_UUID , socialGroup . getUuid ( ) ) ; } } public static class AddHeadOfHousehold implements FormPayloadBuilder { @ Override public void buildFormPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { PayloadTools . addMinimalFormPayload ( formPayload , navigateActivity ) ; PayloadTools . flagForReview ( formPayload , false ) ; CensusFormPayloadBuilders . addNewIndividualPayload ( formPayload , navigateActivity ) ; formPayload . put ( SOCIALGROUP_UUID , IdHelper . generateEntityUuid ( ) ) ; formPayload . put ( RELATIONSHIP_UUID , IdHelper . generateEntityUuid ( ) ) ; formPayload . put ( MEMBERSHIP_UUID , IdHelper . generateEntityUuid ( ) ) ; formPayload . put ( HEAD_PREFILLED_FLAG , "true" ) ; } } public static class EditIndividual implements FormPayloadBuilder { @ Override public void buildFormPayload ( Map < String , String > formPayload , NavigateActivity navigateActivity ) { PayloadTools . addMinimalFormPayload ( formPayload , navigateActivity ) ; PayloadTools . flagForReview ( formPayload , true ) ; Map < String , DataWrapper > hierarchyPath = navigateActivity . getHierarchyPath ( ) ; String individualUuid = hierarchyPath . get ( INDIVIDUAL_STATE ) . getUuid ( ) ; String householdUuid = hierarchyPath . get ( HOUSEHOLD_STATE ) . getUuid ( ) ; IndividualGateway individualGateway = GatewayRegistry . getIndividualGateway ( ) ; ContentResolver contentResolver = navigateActivity . getContentResolver ( ) ; Individual individual = individualGateway . getFirst ( contentResolver , individualGateway . findById ( individualUuid ) ) ; formPayload . putAll ( IndividualFormAdapter . toForm ( individual ) ) ; String truncatedDate = formPayload . get ( DATE_OF_BIRTH ) . substring ( 0 , 10 ) ; formPayload . remove ( DATE_OF_BIRTH ) ; formPayload . put ( DATE_OF_BIRTH , truncatedDate ) ; MembershipGateway membershipGateway = GatewayRegistry . getMembershipGateway ( ) ; Membership membership = membershipGateway . getFirst ( contentResolver , membershipGateway . findBySocialGroupAndIndividual ( householdUuid , individualUuid ) ) ; if ( null != membership ) { formPayload . put ( RELATIONSHIP_TO_HEAD , membership . getRelationshipToHead ( ) ) ; } } } }

Fix:
Individual headOfHousehold = individualGateway . getFirst ( resolver , individualGateway . findById ( socialGroup . getGroupHeadUuid ( ) ) ) ;