Objective
- On inspection detail in Attik mobile, the Contacts section should list people in the same order inspectors see on Attik web—driven by each role’s configured
order(e.g. Clients → Client’s Agent → Listing Agent), not by how rows were added or synced intoinspection.people. - Align mobile with existing company contact-role settings so field staff can scan contacts in a predictable, role-based order.
Background
- Product feedback (Christopher Scott): under Contacts on mobile, users expect contacts top-to-bottom as Clients, then Client’s Agent, then Listing Agent.
- The requirement is that display order matches the
orderfield on populated roles in thepeoplearray—the same sort key companies configure under contact roles. - Attik web already sorts inspection people by
_roleId.order(with a high fallback whenorderis missing) inPeopleBoxbefore rendering. - Attik mobile currently passes
inspection.peoplethrough unchanged;ContactsListmaps the array in API/storage order, so Listing Agent or other roles can appear above Client or Client’s Agent even when role settings say otherwise. - The inspection API already returns
orderon populatedpeople._roleId; mobile types omit it but the value is available at runtime whenpeopleis populated.

Scope
Backend
- Contact roles define
orderoncontactRolesSchema(attik-backend/src/models/contactRolesSchema.ts, default9999). - Inspection reads with
populate: peopleinclude roleorderviapeople._roleIdselect inattik-backend/src/routes/inspection.ts(name,icon,description,portalPermissions,order). Aggregation population inattik-backend/src/util/functions/aggregation/inspectionPopulation.tsmerges full role objects intopeople—no change required unless mobile populate paths differ.
Frontend (reference behavior)
attik-frontend/src/components/ui/PeopleBox.tsxis the parity target:roleDisplayOrderreadsNumber(role.order)with fallback9999,comparePeopleForDisplaysorts people before grouping by role. Mobile should behave consistently with this pattern; exact reuse vs. local helper is a dev choice.
Mobile
- Inspection detail in
attik-mobile/app/(app)/inspection/[id].tsxbuildspeoplefrominspection?.peopleand renders<ContactsList people={people} />with no sort. attik-mobile/components/inspection/ContactsList.tsxmapspeoplein array order.attik-mobile/types/index.ts—ContactRolecurrently has_id,name,typeonly; extending types forordermay be needed for clarity.attik-mobile/hooks/useInspectionDetails.tsanduseInspections.tsrequest populatedpeople—data should includeorderwhen populated.- Also in scope: the deduped
uniquePeoplelist and client-portal dropdown options in[id].tsxare built from the same unsortedpeopleloop; sorting for the Contacts section should keep portal option order aligned with the visible contact list. - Out of scope unless discovered in QA: changing company role
ordervalues in settings; reordering rows insideinspection.peopleon the server.
Decision needed
- Whether to sort in
ContactsListonly vs. a shared sortedpeoplememo in[id].tsx(portal dropdown and any other consumers). - Tie-break when two people share the same role
order(web uses contact id string compare after role order).
References
- Mobile:
attik-mobile/app/(app)/inspection/[id].tsx,attik-mobile/components/inspection/ContactsList.tsx - Web parity:
attik-frontend/src/components/ui/PeopleBox.tsx - API populate:
attik-backend/src/routes/inspection.ts,attik-backend/src/models/contactRolesSchema.ts