App icon indicating copy to clipboard operation
App copied to clipboard

[$500] Tag - Notification shows "tag" instead of custom name for tag

Open lanitochka17 opened this issue 1 year ago β€’ 8 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.33-3 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:

Issue found when executing PR https://github.com/Expensify/App/pull/34482

Action Performed:

Precondition:

  • Admin and employee are part of Collect workspace
  • The Collect workspace has custom name for Tag
  1. [Employee] Go to workspace chat
  2. [Employee] Create a manual expense with tag
  3. [Employee] Navigate to request details page
  4. {Employee] Click tag and select a different tag
  5. [Admin} Note that the notification shows "tag" instead of custom name for tag

Expected Result:

The notification will show custom name for tag instead of the default tag name (Tag)

Actual Result:

The notification shows default tag name (Tag). On Android and iOS app, it shows "changed the request" with no details

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • [x] Android: Native
  • [x] Android: mWeb Chrome
  • [x] iOS: Native
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [x] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/32d2c01e-b207-4858-a9a3-af54963e9d2f

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016118ce4a2a30a489
  • Upwork Job ID: 1752326219551039488
  • Last Price Increase: 2024-01-30

lanitochka17 avatar Jan 30 '24 13:01 lanitochka17

Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] avatar Jan 30 '24 13:01 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~016118ce4a2a30a489

melvin-bot[bot] avatar Jan 30 '24 13:01 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ishpaul777 (External)

melvin-bot[bot] avatar Jan 30 '24 13:01 melvin-bot[bot]

We think that this bug might be related to #wave. CC @zanyrenney

lanitochka17 avatar Jan 30 '24 13:01 lanitochka17

Given this is push notification, I bet this is a back end issue that needs to be fixed internally

cead22 avatar Jan 30 '24 13:01 cead22

Thanks for grabbing it, @cead22!

johncschuster avatar Feb 02 '24 22:02 johncschuster

@cead22, @johncschuster, @ishpaul777 Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Feb 06 '24 15:02 melvin-bot[bot]

Bumping to keep Melvin at bay. How's it going @cead22?

johncschuster avatar Feb 06 '24 23:02 johncschuster

Sorry I'm still a bit behind and haven't gotten to this, but it's on my list

cead22 avatar Feb 07 '24 01:02 cead22

Looking more into this, this isn't a push notification, but a browser local notification, so I think it can be handled externally. There might be an inconsistency between how we show the report action message and the notification, but from a quick look

  • BrowserNotifications.pushModifiedExpenseNotification calls
  • ModifiedExpenseMessage.getForReportAction, which gets policyTagList name and passes it to
  • buildMessageFragmentForValue

So I haven't gotten to the root cause, but I think we can leave that to contributors

cead22 avatar Feb 10 '24 00:02 cead22

Current assignee @ishpaul777 is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar Feb 10 '24 00:02 melvin-bot[bot]

@johncschuster I think External and Help Wanted are the labels to apply to get this through the normal bug process, but correct me if I'm wrong

cead22 avatar Feb 10 '24 00:02 cead22

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] avatar Feb 10 '24 16:02 melvin-bot[bot]

Awaiting proposals

ishpaul777 avatar Feb 10 '24 17:02 ishpaul777

@ishpaul777 I cannot replicate the issue. I cannot see the A B C D option or even the tag option. If the instructions could be revised that would help

jcdiprose avatar Feb 10 '24 17:02 jcdiprose

Hi πŸ‘‹ , @jcdiprose.

A B C D is the custom tag name.

The notification messages are supposed to be constructed from a template such as: change the {customOrTagName} to {newTagValue} (previously "{newTagValue}")

In this example, we want to replace the tag word with the custom tag name, A B C D.

Expected Result

changed the A B C D to "Saturn" (previously "Jupiter")

Actual Result

changed the tag to "Saturn" (previously "Jupiter")

I hope this helps. πŸ€” Since I believe you are new, I don't mind you asking me questions on Slack.

@ishpaul777, Can you confirm? πŸ™

Tony-MK avatar Feb 10 '24 19:02 Tony-MK

Thanks, @Tony-MK What's your name on slack? I have a couple of questions

jcdiprose avatar Feb 10 '24 20:02 jcdiprose

@cead22 @johncschuster @ishpaul777 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Feb 13 '24 15:02 melvin-bot[bot]

not overdue, awaiting proposals

ishpaul777 avatar Feb 15 '24 21:02 ishpaul777

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] avatar Feb 17 '24 16:02 melvin-bot[bot]

bumped on slack for πŸ‘€ https://expensify.slack.com/archives/C01GTK53T8Q/p1708342485959849

ishpaul777 avatar Feb 19 '24 11:02 ishpaul777

Proposal

Please re-state the problem that we are trying to solve in this issue.

The notification for a modified expense in a workspace displays the default word "tag" instead of the custom name for the tag defined in the workspace settings.

What is the root cause of that problem?

The root cause of the issue is that the notification message generation logic does not correctly handle custom tag names. Instead of using the custom name defined in the policy tags, it defaults to using the generic term "tag." This results in the notification displaying "tag" instead of the custom tag name.

https://github.com/Expensify/App/blob/3a95869505bf5165a039eb416d026d4f6d603c99/src/libs/ModifiedExpenseMessage.ts#L196

The line results in "tag" on ios and Android because for some reason, the PolicyUtils doesn't return the proper tag name.

This led me to the actual cause which is PolicyUtils.getTagListName. This function relies on the index of a tag passed in to provide the proper tagList name.

This is likely failing due to the ordering of list changing. I think we should not rely on index to get the tagListName

What changes do you think we should make in order to solve the problem?

  1. Update the getTagListName function to accept a tag key instead of an index:
import _ from 'underscore';
function getTagListName(policyTagList: OnyxEntry<PolicyTagList>, tagKey: string): string {
    if (!policyTagList) {
        return '';
    }

    return _.get(policyTagList, [tagKey, 'name'], '');
}
  1. Update the hasModifiedTag block to use the tag key directly:
if (hasModifiedTag) {
    // same variables

    splittedTag.forEach((newTag, index) => {
        const oldTag = splittedOldTag[index] ?? '';
        const tagKey = `tag_${index}`;

        if (newTag !== oldTag) {
            const policyTagListName = PolicyUtils.getTagListName(policyTags, tagKey) || localizedTagListName;

            buildMessageFragmentForValue(
                PolicyUtils.getCleanedTagName(newTag),
                PolicyUtils.getCleanedTagName(oldTag),
                policyTagListName,
                true,
                setFragments,
                removalFragments,
                changeFragments,
                policyTagListName === localizedTagListName,
            );
        }
    });
}

This change uses the tag key directly, which eliminates the reliance on the order of the keys in the policyTags object. I believe this will fix the issue

brandonhenry avatar Feb 19 '24 16:02 brandonhenry

@cead22 @johncschuster @ishpaul777 this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

melvin-bot[bot] avatar Feb 20 '24 15:02 melvin-bot[bot]

How can I enable notifications on DEV or even staging?

Based on this Slack conversation, it seems contributors aren't able to test iOS notifications.

Come to think of it, I've never received notifications on Android Dev, only the production app. Ditto for the web and desktop app even though I have them enabled.

Victor-Nyagudi avatar Feb 21 '24 12:02 Victor-Nyagudi

@Victor-Nyagudi this is a local browser notification, so I imagine you should be able to allow notifications in chrome to tests this

cead22 avatar Feb 21 '24 18:02 cead22

I have them all on "allow" in site settings, but I don't get anything.

Any idea how I could troubleshoot this, @cead22 ?

What actions usually trigger a notification? Maybe I'm looking for them in the wrong places.

Victor-Nyagudi avatar Feb 21 '24 18:02 Victor-Nyagudi

I remember i got notifications on dev desktop in past for a PR i am reviewing https://github.com/Expensify/App/pull/35004 (on hold for some other PRs for a while), not sure about the web. For native apps i think we only repro. this on a deployed app (or a app with paid apple developer account) (100% sure for ios atleast)

ishpaul777 avatar Feb 21 '24 19:02 ishpaul777

@Victor-Nyagudi can you ask in #expensify-open-source? I don't know the answer but I bet others do, and that way we both learn

cead22 avatar Feb 21 '24 21:02 cead22

I actually tried Slack first before asking here.

Didn't get much traction.

Victor-Nyagudi avatar Feb 22 '24 07:02 Victor-Nyagudi

Has anyone had luck enabling web notifications?

Observations

  1. On Android, the notifications display changed the request.

Android

  1. When disabling Use multiple levels of tags, the created modified expense actions text displays changed the request after changing the tag.

  2. The backend does not synchronize the tags when the Use multiple levels of tags gets disabled and the tag is changed. Hence, the tag's name in the notification seen below displays the previous children's tags.

macOS - Chrome

Tony-MK avatar Feb 24 '24 04:02 Tony-MK