Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tracking] Import phonebook contacts into New Expensify #47938

Open
roryabraham opened this issue Aug 23, 2024 · 21 comments
Open

[Tracking] Import phonebook contacts into New Expensify #47938

roryabraham opened this issue Aug 23, 2024 · 21 comments
Assignees
Labels

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Aug 23, 2024

Proposal: Import phonebook contacts into New Expensify

Strategy
The most important metric we want to see grow in the coming months is new user acquisition 📈. To facilitate that we need to invest in features that streamline viral user growth and make it easier to pull new users into the app. 👥

Problem
If you want to use the Expensify Classic app to invite your team or your boss to Expensify, it’s very easy. You sign up, scan a receipt, and an inbox task will appear asking who you want to send it to. If you click on that, it will open your phone’s contact book and allow you to select the contact(s) that you want to invite to Expensify. You can invite people you know in just a few taps, without leaving the app.

There are a number of other places throughout Expensify Classic where you can easily invite people to Expensify, such as when submitting reports.

Meanwhile, in New Expensify, the first few steps of inviting new users are arguably more streamlined. You immediately scan a receipt, and on the very next page you’ll be asked who you want to share it with. However, at that stage, you need to leave the app to find their email or phone number from some other source and manually type or copy/paste it into NewDot. This introduces friction in a critical viral growth moment.

Solution
Let’s close the gap on one of the final pieces of feature parity between Expensify Classic (mobile) and NewDot, by importing contacts from your phonebook 📕 into New Expensify. This will streamline the process of inviting people you already know into Expensify. Let’s show these imported contacts in any page where we invite new users (start chat, workspace invite, request money participants page, etc…).

All these pages are already set up to invite new users to Expensify via their email or phone number, so the only requirement is to import that information from the contacts app (after obtaining the user’s permission to do so). Because of that, this project is completely front-end and self-contained. That means that after we get through an initial high-level design phase, it can be implemented entirely by external contributors.

For UI inspiration, WhatsApp 📞 shows imported contacts in an “Invite to WhatsApp” section.

@roryabraham roryabraham added the Weekly KSv2 label Aug 23, 2024
@roryabraham roryabraham self-assigned this Aug 23, 2024
@roryabraham
Copy link
Contributor Author

First predesign questions:

  • How should we show these?

    • I suggest we just show a new section in selection lists titled Invite to Expensify, styled the same as the existing Recents and Contacts sections:
    image
  • Should we try to support web?

    • I suggest no (for the V1, anyways). There's an experimental ContactsManager web API, but it only works on Android atm. Furthermore, it doesn't support importing all contacts and displaying them using our own UI. Instead, it's more like what we have in OldApp that pulls up the native contacts app and allows you to select contacts to import.
  • Should we try to support desktop?

    • I suggest yes. It may be a bit involved to set up, but fortunately our needs should be pretty simple. It might look something like this:
      • Use the same Swift code to access contacts on macOS and iOS. CNContactsStore works on both.
      • Use the same C+code on iOS and macOS to create C++ bindings for the swift code
      • (here's where things start to differ) on desktop, create a Node.js addon with JS bindings to the C++/Swift code
      • Require the Node.js addon in desktop/main.ts
      • Use the Electron context bridge to provide a renderer process interface for the Node.js code that can be used to access contacts
  • Should we use a library for this?

    • There are a couple of options, such as react-native-contacts and expo-contacts. However, because the native code should be quite simple and none of the existing solutions support (or would be expected to support) Electron, I suggest we just create our own small library for this.

@roryabraham
Copy link
Contributor Author

posted first predesign (saving library/implementation details for a 2nd predesign):

https://expensify.slack.com/archives/C01GTK53T8Q/p1724440169163019

@melvin-bot melvin-bot bot added the Overdue label Sep 2, 2024
@trjExpensify
Copy link
Contributor

Posted here, but I don't think this is a project for #wave-collect.

@roryabraham
Copy link
Contributor Author

Moved to #f1-25june2025

@melvin-bot melvin-bot bot removed the Overdue label Sep 2, 2024
@roryabraham
Copy link
Contributor Author

@roryabraham
Copy link
Contributor Author

Summarizing all of our predesign decisions and getting this ready for handoff:

  • When revealing users imported from contacts which aren't yet an Expensify contact, we'll show them just like any other user. We won't draw any additional attention to the fact that they don't yet have an Expensify account, and won't introduce a new Invite section to selection lists
  • Every time SelectionList mounts, we'll:
    • verify we have permission to access contacts.
      • If the user has given permission to access contacts, proceed to the next step.
      • unless the user has explicitly denied permission, request permission to access contacts, then proceed to the next step
    • import all phonebook contacts, include them in the SelectionList result set
  • If a user has explicitly denied permission to access contacts, and have entered a search query which yields no results, then instead of simply showing No results found, we would show:
    Not seeing who you're looking for? Want to [import your phonebook contacts](link)?
  • Only iOS and Android are in-scope for the V1. I think the V2 can target desktop as well, maybe web in a (distant) V3 if the web API improves.
  • We should show a user's contact photo when searching for them and they don't yet an Expensify account.
  • If they do have an Expensify account, but their Expensify account is using a default avatar, and your phonebook contact has an avatar for them, then we should show your phonebook avatar for the user rather than their default Expensify avatar
  • Let's also roll-our-own small amount of native code for this directly in E/App rather than using or publishing a separate package. Let's use Nitro Modules for this native code.

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2024
@roryabraham
Copy link
Contributor Author

@melvin-bot melvin-bot bot removed the Overdue label Sep 19, 2024
@perunt
Copy link
Contributor

perunt commented Sep 23, 2024

👋🏻

@s77rt
Copy link
Contributor

s77rt commented Sep 24, 2024

You can use https://github.com/s77rt/react-native-contacts (a Turbo Module) for reference

@blimpich blimpich self-assigned this Sep 26, 2024
@melvin-bot melvin-bot bot added the Overdue label Oct 4, 2024
@blimpich
Copy link
Contributor

@perunt how is the PR going? Can you you give us an update?

@melvin-bot melvin-bot bot removed the Overdue label Oct 14, 2024
@perunt
Copy link
Contributor

perunt commented Oct 15, 2024

hey @blimpich, we just finished fixing the Nitro issue (the library we use for this module). Tomorrow, I'm going to show some metrics about it and move that module to the Expensify repo

@blimpich
Copy link
Contributor

Sounds great! Thank you for the update 👍

@perunt perunt mentioned this issue Oct 17, 2024
50 tasks
@perunt
Copy link
Contributor

perunt commented Oct 23, 2024

You can use https://github.com/s77rt/react-native-contacts (a Turbo Module) for reference

Thanks for the link! I'll use it for an approximate comparison between NitroModule and TurboModule

@perunt
Copy link
Contributor

perunt commented Oct 24, 2024

While this isn't the perfect comparison since both modules are built differently under the hood and could probably be optimized further, it gives us a decent starting point.
I ran some tests importing around 1,100 contacts - did it 20 times with 10-second breaks between runs to get the average times. Maybe we don't have huge differences, but we definitely see the cost of overhead.

iPhone XR Samsung S21

Nitro is running about 30% faster on iOS and 10-20% faster on Android compared to TurboModules

Since we're getting responses under 100ms, it's actually faster than receiving data from the internet (at least for importing 1k contacts) - it allows us to work without using fetch from the backend (in case when we save it).

@mrousavy
Copy link
Contributor

woohooooo!!! huge 🔥

@shubhamguptadream11
Copy link

@perunt Can you share the nitro module repo link where you did the benchmarks.

Copy link

melvin-bot bot commented Nov 1, 2024

📣 @shubhamguptadream11! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@perunt
Copy link
Contributor

perunt commented Nov 1, 2024

@shubhamguptadream11 this was my sandbox, link
I will update and clean it later, and add screenshots to that repo

@perunt
Copy link
Contributor

perunt commented Nov 1, 2024

I'm adding the last features - 'use photo from contact book for contacts from Expensify that don't have an avatar.' The second ability is that when you pick a user from contacts, you create this user for the Expensify account. Due to our current structure, it's a bit tricky to use the photo for creating this contact on the next screen. I mean to port this photo. Apart from this, everything is working.
So I'm starting to think if we need to deliver it in one PR or maybe spread it. I know that if you check the amount of code, it would be around 50k lines, but I want to say that 95% is auto-generated code. I'll also mention this in the PR for reviewer.
What do you think? @blimpich (I mean deliver it as one PR or spread it)

@blimpich
Copy link
Contributor

blimpich commented Nov 1, 2024

@perunt I think splitting it up is a good idea. I think if that functionality is particularly tricky, it's preferable to break it up so that we can review and test separately. We would just use one of the randomly picked default avatars instead of the contact photo in the first PR correct?

@melvin-bot melvin-bot bot added the Overdue label Nov 11, 2024
@blimpich
Copy link
Contributor

Not overdue. I see recent progress made on the PR. @perunt any updates to share? Did you decide to split the functionality into multiple PRs like you suggested here?

@melvin-bot melvin-bot bot removed the Overdue label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

7 participants